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

LoadCharacter is giving me errors about how the player is not in the world?

So I am trying to respawn all the players with LoadCharacter on the server but I am getting the error "LoadCharacter can only be called when Player is in the world."

My script:

function SpawnPlayers()
	print("Spawining Players")
	for i, player in ipairs(players) do
		player:LoadCharacter()
	end
end

1 comment

0

It means the player has not join the game yet

1 answer

✓ Accepted answer

You are probaly using the "players" in line 3 as a varible that says "game.Players:GetPlayers()" or "game.Players:GetChildern()" but when you do that, it does not do the players in a table again. So it tries to put all the players in a table when you assing the table. But then the players are not in the game yet. So you should instead use

	function SpawnPlayers()
	    print("Spawining Players")
	    for i, player in in pairs(game.Players:GetPlayers()) do
	        player:LoadCharacter()
	    end
	end
 

so it will go through all the players that are currently in the game and not only the players when you assinged the table. I hope this helps

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