The whole operation can infact be done from the server side, as a clickdetecter being clicked ( as shown as the initiation of the giving in the initial script above ), can infact be detected by a server-side script.
From your script, I can see you have used LocalPlayer, which is part of a local script. A local script is not the correct type of script you should be using in this context, and I'll explain why. A local script's effect is purely seen on the side of the client it's executed inside of. This means that neither the server nor any other player knows of what happens in this script, meaning in this case, only the player that clicked the clickdetector would "know" of the cloned tool. A server-script, however, is automatically broadcasted to all clients, and therefore is able to achieve the effect I believe you are trying to achieve.
Here is the script I used in my test:
tool = script.TestTool
clickdetector = workspace.TestPart.ClickDetector
clickdetector.MouseClick:Connect(function(plr)
local clone = tool:Clone()
clone.Parent = plr.Backpack
end)
Put this in ServerScriptService, and place your tool inside of the script.To adapt, just change the routes of the variable tool, and the clickdetector.
Hope this helped.
2 comments
Any errors?
None show up, it just won't work unless I have to play it via actual roblox