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.
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)