I want to create a script that would count how many players are current IN the game and connected, this will help me create a minigame script that knows not to start if there's not a certain number.
COMMUNITY QUESTION
How to count connected players?
4 answers
Just use the :GetChildren() of the player service:
print(#game.Players:GetChildren()) -- Would print number of players
Or you could do this by using the GetPlayers() method.
print(#game.Players:GetPlayers())
What about not allowing the script to start without players? Would that be
if #game.Players:GetChildren == 5 then
message.Text = ("Starting Game!")
elseif #game.Players:GetChildren == >5 then
message.Text = "We need " ..players
Obviously will create the ..players var but just for reference.
There's a read-only NumPlayers property in Players.
print(game.Players.NumPlayers)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This is from 8months ago.
¯_(:/)_/¯