I was wondering how i could make a script that prints all the people in the server and if they are nil tell me one of my friends made this one:
local PlayerName='iiXynx'; local inGame,Player=pcall(function()return(game:service'Players'[PlayerName]); end); if(not inGame)then print(string.format('Player %s is not in the Players instance.',PlayerName)); else print(Player,' is here.'); end;
but this only shows me if one person is in or not and it also doesnt tell me if they are nili was just wondering if anyone knows how?
~Thanks, Derpy~
Just use NetworkServer, and check if each player is not parented to Player.
local Players={}; for _,Player in next,game:service'NetworkServer':children() do if( Player:isA'ServerReplicator'and Player:getPlayer() )then--// Checks if they are a fully joined player, and if they are actually a player. Players[Player:getPlayer().Name]={ Player, Player.Parent~=game:service'Players', }; end; end;
In the Players table, the first argument would be the Player, then the second would be if they are "nil."
To print them, just do,
if( Player:getPlayer().Parent~=game:service'Players' )then print(string.format('%s is not ingame.',Player:getPlayer().Name)); end;