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?
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")