Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tool not cloning to backpack?

This is what I currently have and it doesn't work. There is also no error in the output.

local tools = game.ReplicatedStorage.Tools

game.Players.PlayerAdded:Connect(function(player)
	tools.Plank:Clone().Parent = player.Backpack
end)

2 comments

0

is it in a local script or a normal script?

0

It is probably in a normal script because I think that is the only way to access it on a server script.

4 answers

I had such a problem before. I fixed it by making the ClonedTool a variable

local tools = game.ReplicatedStorage.Tools

game.Players.PlayerAdded:Connect(function(player)
    local clonedTool = tools.Plank:Clone()
    clonedTool.Parent = player.Backpack
end)

This feels like the same thing, but it somehow worked for me.

im not sure but i think you define player like uh

player = game.Players

2 comments

0

or something like this

0

bro what? smh

Maybe the backpack wasn't loaded in yet when the script was loaded. Try :WaitForChild() or check if the backpack is loaded and then select it. Here is an example:

local tools = game.ReplicatedStorage:WaitForChild("Tools")
game.Players.PlayerAdded:Connect(function(player)
tools.Plank:Clone().Parent = player:WaitForChild("Backpack")
end)

By doing this, your waiting for the backpack to load, and once it loads, the tool will be in the backpack! Also tools.Plank:Clone() should be in a variable.

You maybe need to use CharacterAdded

local tools = game.ReplicatedStorage.Tools

game.Players.PlayerAdded:Connect(function(player)
   player.CharacterAdded:Connect(function(character)
    tools.Plank:Clone().Parent = player.Backpack
     end)
end)

This will wait until the player Character to load before cloning.

This discussion is preserved as it was. New answers, comments, and votes are closed.