Is there an efficient way to wait for the character to load?

As stated in the title, Is there a better way to wait for the player?

Currently, I’m waiting 3 seconds; which can sometimes not work as I get the error ServerScriptService.Script:18: attempt to index nil with 'WaitForChild'.

	local Char
	player.CharacterAppearanceLoaded:Connect(function()
		Char = player.Character
	end)
	
	wait(3)
	
	Char:WaitForChild("Humanoid").Died:Connect(function()
		Alive.Value = false
	end)

Help? Thanks.

1 Like

Perhaps use repeat wait() until player.Character. Not sure if you have considered that or it helps with your issue.

1 Like

No, I did not think of that. But it works. Thanks!

for people that might need help with the same issue

Do

repeat wait() until player.Character

No problem. Happy to help. Remember to mark the comment that answered your question as the solution, so people won’t get confused and answer the topic again.

I would just use the Player.CharacterAdded event and do:

local Char = Player.Character or Player.CharacterAdded:Wait()
4 Likes