I am making a script where the player presses a tool, and it goes into their inventory. However, when I click it, it doesn’t do anything. It is a local script located inside the tool.
Insert a script inside the part, not a localscript
Use PlayerWhoClicked rather than localplayer
script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked) --function
local player = playerWhoClicked --player who clicked
local tool = script.Parent.Tool --index the tool and the tool name
local newtool = tool:Clone() --clone it
newtool.Parent = player.Backpack --clone it into the players backpack
end)
Try Parenting the tool to serverstorage.
(and make sure that it is a NORMAL script
script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked) --function
local player = playerWhoClicked --player who clicked
local tool = game.ServerStorage.Tool --index the tool and the tool name
local newtool = tool:Clone() --clone it
newtool.Parent = player.Backpack --clone it into the players backpack
end)