I'm trying to make a script so that when someone clicks on a button, it gives them the script's parent (in this case, a tool). Where did I go wrong here?
local debounce = false function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onClick(part) local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then debounce = true local player = getPlayer(human) if (player == nil) then return end script.Parent:clone().Parent = player.Backpack wait(2) debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClick)