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

Can't find a way to get the character from the player?

this is my code but I keep getting this error: ServerScriptService.Script:5: attempt to index nil with 'Character'

game.Players.PlayerAdded:Connect(function(player)
	print(player.name "joined")
end)

if not player.Character then
    print("waiting for character")
    player.CharacterAdded:wait();
    char = player.Character
else
    char = player.Character
end

1 answer

✓ Accepted answer

put your if statement inside the function. Your if statement does not know what player is because the player is a parameter of the function and it is only available for code inside the function (someone please explain this better).

1 comment

0

Thank you this was really helpful!

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