Is it possible that the player's character is loaded before Players.PlayerAdded is fired?

While reading some scripts I came across this code

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
	if player.Character then --here it is assumed that there could be a character
		onCharacterAdded(player.Character)
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)

What makes suppose that the character can be loaded before the PlayerAdded event is fired. Is it possible that this happens?

No, The character will be generated after PlayerAdded is called.

1 Like
local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
	if player.Character then -- This checks if the player's character loaded
		onCharacterAdded(player.Character)
	end
end

Players.PlayerAdded:Connect(onPlayerAdded) -- this connects the PlayerAdded event to the function
1 Like