How to check how many players there are in a server?

I’m wondering how to check how many players are in a server when a new server starts. How can I do that?

local Players = game:GetService('Players')
local PlayerInServer = #Players:GetPlayers()

This code will return the number of players online in the server

5 Likes

Like what @Sebastian_Wilson suggested, you can call game:GetService("Players"):GetPlayers() which returns a table of all the players. Then you can use the # length operator which returns how many values are in a table (only works for arrays).

1 Like

It works! Thank you very much! :smile:

1 Like