So I'm trying to clone a tool from ReplicatedStorage to the players Backpack but it isn't working for some reason. Her'es the script:
script.Parent.ClickDetector.MouseClick:connect(function() local clone = game.ReplicatedStorage.Pyro:Clone() local player = game.Players.LocalPlayer clone.Parent = player.Backpack end)
I've also tried this:
local player = game.Players.LocalPlayer local clone = game.ReplicatedStorage.Pyro:Clone() script.Parent.ClickDetector.MouseClick:connect(function() clone.Parent = player.Backpack end)
But none work. Been trying to get this to work since Yesterday, I asked on the ROBLOX forums but no one was giving me a correct solution.
This is in a local script inside a part with a ClickDetector
Here is how I would have done it;
First off, your script is most likely in a game service that will not get put into a player, what do I mean by that? By that I mean, if you put a local script in Workspace, workspace has no Local player which means the local script cannot find the player to clone the tool into.
I have changed the script some what but here it is, it works for me.
It is a Local Script in ScreenGui and the part with the click detector is called "AToolGiver" and is stored in Workspace.
local player = game.Players.LocalPlayer local cd = game.Workspace:WaitForChild("AToolGiver") local copy = game.ReplicatedStorage:WaitForChild("Pyro") cd.ClickDetector.MouseClick:connect(function() copy:Clone().Parent = player.Backpack end)