Advertisement
seeseekeepeeshee

Untitled

Jun 6th, 2025
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ServerStorage = game:GetService("ServerStorage")
  3. local Tool = ServerStorage:WaitForChild("PEWPEW")
  4. local Zone = workspace:WaitForChild("WeaponZone")
  5.  
  6. -- Keep track of who has the tool
  7. local playersWithTool = {}
  8.  
  9. Zone.Touched:Connect(function(hit)
  10. local character = hit.Parent
  11. local player = Players:GetPlayerFromCharacter(character)
  12. if player and not playersWithTool[player] then
  13. -- Give the tool
  14. local toolClone = Tool:Clone()
  15. toolClone.Parent = player.Backpack
  16. playersWithTool[player] = toolClone
  17. end
  18. end)
  19.  
  20. Zone.TouchEnded:Connect(function(hit)
  21. local character = hit.Parent
  22. local player = Players:GetPlayerFromCharacter(character)
  23. if player and playersWithTool[player] then
  24. -- Remove the tool
  25. local tool = playersWithTool[player]
  26. if tool and tool.Parent then
  27. tool:Destroy()
  28. end
  29. playersWithTool[player] = nil
  30. end
  31. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement