XxxLloyd061302xxX

Buy Button Script

May 29th, 2018
3,986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. local price = script.Parent.Parent.Price
  2. local tools = game.ReplicatedStorage:WaitForChild("Tools")
  3. local tool = tools:FindFirstChild(script.Parent.Parent.ItemName.Value)
  4. local player = script.Parent.Parent.Parent.Parent.Parent.Parent
  5.  
  6. script.Parent.MouseButton1Click:connect(function()
  7. if player.leaderstats:FindFirstChild("Money").Value >= price.Value then -- Change "Money" to the name of your currency. Example: Cash
  8. player.leaderstats:FindFirstChild("Money").Value = player.leaderstats:FindFirstChild("Money").Value - price.Value
  9. local clone = tool:Clone()
  10. clone.Parent = player.Backpack
  11. -- Copy this code if you want the player to still have the tool even if he died
  12. local clone2 = tool:Clone()
  13. clone2.Parent = player.StarterGear
  14. end
  15. end)
Add Comment
Please, Sign In to add comment