Player not in world

   wait(1) -- they leave or something here
	if player and player.Parent == Players then
		player:LoadCharacter()
	end

gives this error. How could it be? Would their parent not cease to be Players? Why wouldn’t player reference be gone in the first place, from:
game.Players.PlayerAdded:Connect(function(player)

What error does the code give. Its hard to figure out the problem from little information.

Although, maybe, if you haven’t set the players service to the Players variable, then maybe thats the issue. The game doesn’t know what “Players” is; you have to write game.Players in your second line:

wait(1) -- they leave or something here
	if player and player.Parent == game.Players then
		player:LoadCharacter()
	end
1 Like

Player not in the world is the error. I think I beat it back with if Players[player.Name] now, but we’ll see because it takes some time for it to arise in my servers.

And thinking through your code, if Players was anything other than players it would most certainly be false, and then the error couldn’t occur because if player and false wouldn’t run. But sorry if I mislead you, I’ll be sure to post the error log next time it was player:LoadCharacter() :wink:

Never seen this error before. Would appreciate an actual console screenshot of this happening and a full repro code sample that gives the same error.

Oh well my fix should’ve been if player and Players:FindFirstChild(player.Name) as here is a familiar error:


It’s rare because a player has to leave right after they die, yes, for all I am doing here is waiting a second in this case after to respawn them, and, if they leave the player object persists its parent. As if it’s entered a static state, contrarily, Players is still online, it can be used to detect that the player is departed, for it is a member of the ‘World’, which I don’t know what said World is. Presumably the rank over the game itself?

game.Players.PlayerAdded:Connect(function(player) 
	player.CharacterAppearanceLoaded:Connect(function(character)							 
		character.Humanoid.Died:Connect(function()		
			wait(1)	 
			if player.Character then player.Character:Destroy() end
			wait(1) 
			if player and player.Parent == Players then -- this is right,
				player:LoadCharacter()	-- even when they are gone		
			end  -- so the above, used below previously gave orig. error
		end)		 
	end)
	wait(1)
	if player and Players:FindFirstChild(player.Name) then --the fix
		player:LoadCharacter()
	end
end) 

Note that looking at this if some player died before CAL they won’t respawn now that I am realizing, yuck, also I did not repair it in the died event, which I’ll get to in spite of no errors present.

tl;dr check if Players contains Player not if Player’s Parent is Players (updated 5/9/22)

Have you defined Players as game:GetService(“Players”)?

local Players = game:GetService("Players") yes that’s kind of low fruit

I don’t actually know what you are trying to achieve.