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

Tool does not get cloned to players backpack and outputs error?

Hi I have a script that basically just clones a tool and puts it in the players backpack. But I keep getting the error:

"Backpack is not a valid member of player"

I am almost certain I am referencing the right thing and this is very very confusing cause I have done very similar stuff before and it has worked.

Here is my code. SERVER SCRIPT

game:GetService("Players").PlayerAdded:connect(function(player) 
	if player.Name == "iladoga" or player.Name == "FrostyMan88" then
		local cloene = game:GetService("ServerStorage")["Founders Machete"]:Clone()
		cloene.Parent = player.Backpack
	end
end)

Again it just outputs that error. Thank you for taking your time looking at this.

2 comments

1

Try doing player:WaitForChild('Backpack'). Sometimes the Backpack doesn’t load in fast enough which makes your script error.

0

what he said and in general you wanna wait for player and his descendants, such as character humanoid backpack etc...

1 answer

✓ Accepted answer
game:GetService("Players").PlayerAdded:connect(function(player) 
    if player.Name == "iladoga" or player.Name == "FrostyMan88" then
	player:WaitForChild("Backpack")
        local cloene = game:GetService("ServerStorage")["Founders Machete"]:Clone()
        cloene.Parent = player.Backpack
    end
end)

1 comment

2

I hate to be that guy but :connect() is deprecated. Also it might be better to tell the person what's wrong instead of giving them a script to copy and paste.

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