Ok, so basically I'm scripting a thing that doesnt clone the tool, it sets a new parent.
The script:
local robot = script.Parent.Robot local starterpack = game.StarterPack local Players = game:GetService("Players") script.Parent.ClickDetector.MouseClick:connect (function(plr) robot.Parent = game.Players.LocalPlayer.Backpack end)
As in output, when i click. It says: Workspace.Part.Script:8: attempt to index nil with 'Backpack
Can somebody help?
I can't help you with your real question but consider using the advice below.
connect is deprecated use "Connect", remove the space in between connect and the function.
local robot = script.Parent.Robot local starterpack = game.StarterPack local Players = game:GetService("Players") script.Parent.ClickDetector.MouseClick:Connect(function(plr) robot.Parent = game.Players.LocalPlayer.Backpack end)
Also, why did you make a variable for starterpack but didn't use it?
And the final question, is "robot" a tool?
LocalPlayer is not a valid child in any regular server script. This might help a bit:
local robot = script.Parent.Robot script.Parent.ClickDetector.MouseClick:Connect(function(plr) local clone = robot:Clone() clone.Parent = plr.Backpack end)
You can't get the LocalPlayer in a normal script. MouseClick's first variable is the player who clicked, so you can clone the tool to the player's backpack.
local robot = script.Parent.Robot local starterpack = game.StarterPack local Players = game:GetService("Players") script.Parent.ClickDetector.MouseClick:Connect(function(plr) robot.Parent = plr.Backpack -- Here's the change end)
Hope this helps!