I have a script that I want to destroy after it gives the player 1 coin.Does anybody know a script for that? Script: script.Parent.Touched:connect(function(part) if game.Players:findFirstChild(part.Parent.Name) then local plr = game.Players:findFirstChild(part.Parent.Name) plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1 end end)
✓ ANSWER ACCEPTED
Is there any way to make this brick destroy after it gives 1 coin?
1 answer
✓ Accepted answer
When you want to destroy it all you literally do is use the :Destroy() function. Also, I have added a debounce that basically makes sure the player only gets 1 coin instead of hundreds.
If this is what you were looking for please make sure to accept my answer
local debounce = true
script.Parent.Touched:connect(function(part)
if debounce then
debounce = false
if game.Players:findFirstChild(part.Parent.Name) then
local plr = game.Players:findFirstChild(part.Parent.Name)
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
script.Parent:Destroy()
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
