To start off, there's a couple of things you're doing wrong: if you're using a script to do this, you're trying to use 'LocalPlayer', which can only be used by LocalScripts. If you're using a LocalScript, you're trying to access ServerStorage, which isn't replicated to clients, and thus can't be accessed by LocalScripts. Also, while this isn't necesarrily a flaw, you should always use :WaitForChild() on things when using a LocalScript.
For example:
script.Parent.ClickDetector.MouseClick:connect(function() end)
script.Parent:WaitForChild("ClickDetector").MouseClick:connect(function() end)
So, I'm assuming that you just have a part in Workspace with a script in it that, when clicked, will clone a tool into the backpack of the player who clicked it. To do that, we'll just use this little code:
local cD = Instance.new("ClickDetector", script.Parent)
local tool = game.ServerStorage['ExampleTool']
cD.MouseClick:connect(function(c)
if not c.Backpack:FindFirstChild(tool.Name) then
tool:Clone().Parent = c.Backpack
end
end)
And that's that.
Hope this helps.
1 comment
""The MouseClick event must be handled by a Script.""