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

how can i do count player in sever ?

I want to know how many players are in the server, how do I do this?

1 answer

✓ Accepted answer

You pretty much create a table with the player list and loop it in order to check on how many users are in that table. You can use either a local or server script for this and just do something along these lines.

local players = game.Players:GetChildren()


function CountPlayers()

local number = 0

for _, value1 in pairs (players) do

number = number + 1

end

return number

end


print(CountPlayers())

2 comments

0

Or just,, you know,,, print(#game.Players:GetPlayers()),,

0

-1 for using :GetChildren on players, use :GetPlayers, and for reinventing the wheel

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