I have been trying the old script
01 local debounce = false 02 03 function getPlayer(humanoid) 04 local players = game.Players:children() 05 for i = 1, #players do 06 if players[i].Character.Humanoid == humanoid then return players[i] end 07 end 08 return nil 09 end 10 11 function onTouch(part) 12 13 local human = part.Parent:findFirstChild("Humanoid") 14 if (human ~= nil) and debounce == false then 15 16 debounce = true 17 18 local player = getPlayer(human) 19 20 if (player == nil) then return end 21 22 script.Parent:clone().Parent = player.Backpack 23 24 wait(2) 25 debounce = false 26 end 27 end 28 29 30 script.Parent.Parent.Touched:connect(onTouch)
This is the one that doesn't work.
So I tried fixing it but it still didn't work. Can you help me?
Change line 22 to something to point to where you have your gear such as serverstorage...
game:GetService("ServerStorage").YOURGEAR:clone().Parent = player.Backpack
What your going to have to do is detect when the part is touched on the server, then clone a tool to their backpack (or character for instant equip).
local Player = game:GetService('Players') local Tool = script.Tool -- Put the tool in the script local Part = workspace.Part -- Define the part here local Debounce = false Part.Touched:Connect(function(Obj) if Debounce then return end Debounce = true local Player = Players:GetPlayerFromCharacter(Obj.Parent) if Player then Tool:Clone().Parent = Player.Backpack wait(1) Debounce = false end end)
Closed as Not Constructive by hiimgoodpack and royaltoe
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?