Advertisement
menyezisplayzz

Coin script

Jul 31st, 2021
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. 📜Coin Script📜
  2.  
  3.  
  4. WaitTime = 5 -- How many seconds to respawn the coin!
  5. Amount = 1 -- Amount of coins per coin!
  6. function onTouched(part)
  7. local h = part.Parent:findFirstChild("Humanoid")
  8. if (h~=nil) then
  9. local thisplr = game.Players:FindFirstChild(h.Parent.Name)
  10. if (thisplr~=nil) then
  11. local stats = thisplr:findFirstChild("leaderstats")
  12. if (stats~=nil) then
  13. local Score = stats:findFirstChild("Coins")
  14. if (Score~=nil) then
  15. Score.Value = Score.Value + Amount
  16. end
  17. end
  18. end
  19. script.Parent.Transparency = 1
  20. script.Disabled = true
  21. wait(WaitTime)
  22. script.Parent.Transparency = 0
  23. script.Disabled = false
  24. end
  25. end
  26.  
  27. script.Parent.Touched:Connect(onTouched)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement