Hey guys, I got this error message:
22:12:22.155 - LoadCharacter can only be called when Player is in the world 22:12:22.168 - Script 'ServerScriptService.Script', Line 96 - global Classic 22:12:22.175 - Script 'ServerScriptService.Script', Line 189 - global ChooseRound 22:12:22.178 - Script 'ServerScriptService.Script', Line 202 22:12:22.180 - Stack End
Here is where I think the problem lies:
for i = 1,#players do if players[i] then players[i].TeamColor = game.Teams['Not Playing'].TeamColor players[i]:LoadCharacter()end --This is line 96 end
Why am I getting this error message even though I have put in a check to see if the player ~= nil?
if players[i] then
will always be true. A player is not nil if it is not in players; it still is a player. Instead, write if players[i].Parent then
to make sure that they are still there. LoadCharacter
cannot be called otherwise.
local players = Game.Players:GetPlayers() for i = 1, #players do players[i].TeamColor = game.Teams['Not Playing'].TeamColor players[i]:LoadCharacter() end
This should work fine? My guess is that your table "players" has something wrong with it.