Advertisement
Cakey3101

Gems Handler - EP 2

Apr 16th, 2025
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | Source Code | 0 0
  1. local Players = game:GetService("Players") -- Getting The Players Service
  2.  
  3. for _, child in script.Parent:GetChildren() do -- Looping Through All The Children In The Folder
  4.     if child.Name == "Gem" then
  5.         child.Touched:Connect(function(OtherPart: BasePart) -- Listening To When It Is Touched
  6.             local Character = OtherPart.Parent -- Getting The Character
  7.             local Player = Players:GetPlayerFromCharacter(Character) -- Getting The Player
  8.            
  9.             if Player then
  10.                 child:Destroy() -- Destroying The Gem (So They Can Only Claim It Once)
  11.                 Player.leaderstats.Gems.Value += 1
  12.                 script.Parent.Sound:Play() -- Playing The Sound
  13.                 script.Enabled = false
  14.                 task.wait(0.5)
  15.                 script.Enabled = true
  16.             end
  17.         end)
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement