OnFireRobloxScriptin

Touch to collect coin (Destroy Version)

Jul 7th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. --//Variables
  2. local coin = script.Parent --Variable for coin
  3.  
  4. coin.Touched:Connect(function(hit)
  5.     if hit.Parent:FindFirstChild("Humanoid") then --Checks for players
  6.         local char = hit.Parent --Gets character
  7.         local player = game:GetService("Players"):GetPlayerFromCharacter(char) --Gets player
  8.         local leaderstats = player:FindFirstChild("leaderstats") --Find leaderstats
  9.         if leaderstats then --Checks for leaderstats
  10.             leaderstats.Cash.Value += 50 --Give Cash
  11.         end
  12.         coin:Destroy() --Destroy Coin
  13.     end
  14. end)
Add Comment
Please, Sign In to add comment