Player:WaitForChild("Character") causing infinite wait

game.Players.PlayerAdded:Connect(function(plr)
    local char = plr:WaitForChild("Character")
    repeat wait() until char
  	print("Character loaded.")
end)

So I was making a script and noticed that all functions that are involved with the character were not working. I got suspicious so I made this script and got a warning saying an infinite yield is possible. I checked the player and the character was set. Why is this happening?

Character is a property of the Player, not an Instance. If you want to get or wait for the character you should use
local char = plr.Character or plr.CharacterAdded:Wait()

1 Like

Player.CharacterAdded:wait() worked, Thanks! :smile::+1: