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

Why isn't this script working?

So I was making a script to insert a tool into a player's startergear when they join. Here's the script:

function PlayerAdded(player)
if player.Name == workspace.ToolValues.Tool.Value then
game.ServerStorage.Tool:Clone().Parent = game.Players[player.Name].StarterGear
end
end
game.Players.PlayerAdded:connect(PlayerAdded)

When I try this, it says "StarterGear is not a valid member of Player" Any thoughts as to why this isn't working?

1 answer

✓ Accepted answer

It is likely that you are trying to gain access to StarterGear before it is created. Try adding a WaitForChild method call on line 3:

game.ServerStorage.Tool:Clone().Parent = game.Players[player.Name]:WaitForChild("StarterGear")

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