of     1   

Epicgamerz0
#184468839Sunday, February 28, 2016 12:43 PM GMT

Ok, so I have a leaderstat that represents money in my game. I want to make a button that you step on, and if you have enough "money" it will give you a tool. How do I pull this off?
benthanh123
#184468898Sunday, February 28, 2016 12:46 PM GMT

Touch event If statement Clone tools and parent
Naco88
#184468980Sunday, February 28, 2016 12:49 PM GMT

Door = script.Parent local debounce = false function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Money") --Change "Money" to the type of currency you have. if sp == nil then return false end if (sp.Value >=0) then --Amount of how much the weapon will go for,Change "100". sp.Value = sp.Value - 0 --Put the same exact number here as you did above. print("Enough Money") game.Lighting.PUTTOOLNAMEHERE:clone().Parent = player.Backpack --Change PUTTOOLNAMEHERE to your weapons name. Door.BrickColor = BrickColor.new(21) --MAKE SURE YOU PUT THE WEAPON/TOOL INTO LIGHTING. wait(2) Door.BrickColor = BrickColor.new(37) --Leave the rest of this alone. debounce = false else debounce = false end end end connection = Door.Touched:connect(onTouched) -- Paste this into a script and put it in a block.
Naco88
#184468994Sunday, February 28, 2016 12:50 PM GMT

Oh yeah and put the tool in lighting and change "PUTYOURTOOLNAMEHERE" to the name of it e.g. "gun".
Epicgamerz0
#184470247Sunday, February 28, 2016 1:34 PM GMT

That won't work. Did I do something wrong? Door = script.Parent local debounce = false function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Money") --Change "Money" to the type of currency you have. if sp == nil then return false end if (sp.Value >=5) then --Amount of how much the weapon will go for,Change "100". sp.Value = sp.Value - 5 --Put the same exact number here as you did above. game.Lighting.Coffee Cup:clone().Parent = player.Backpack --Change PUTTOOLNAMEHERE to your weapons name. Door.BrickColor = BrickColor.new(21) --MAKE SURE YOU PUT THE WEAPON/TOOL INTO LIGHTING. wait(2) Door.BrickColor = BrickColor.new(37) --Leave the rest of this alone. debounce = false else debounce = false end end end connection = Door.Touched:connect(onTouched)
Naco88
#184470310Sunday, February 28, 2016 1:36 PM GMT

Possibly the line: game.Lighting.Coffee Cup:clone().Parent = player.Backpack --Change PUTTOOLNAMEHERE to your Coffee Cup has a space in the name which may be a problem. Change this line to CoffeeCup and change the name of the tool in lighting to CoffeeCup and try it (No spaces).
Epicgamerz0
#184470498Sunday, February 28, 2016 1:42 PM GMT

Ok, doing it now...
Epicgamerz0
#184470652Sunday, February 28, 2016 1:47 PM GMT

It works now! Thank you for your help.
Naco88
#184548609Monday, February 29, 2016 9:11 PM GMT

Happy to help!

    of     1