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

How do I find the number of players in a game?

Okay so I need to find the amount of players in my game. Basically I want to use a if/then statement. Here is the type I want to use:

if AmountOfPlayers >= 2 then -- AmountOfPlayers is the part I don't know
game.Workspace.MainScript.Disabled = false
elseif AmountOfPlayers <= 1 then
game.Workspace.StringValue.Value = "Wait for more players"
end

1 answer

✓ Accepted answer

There is a property of the Players service called NumPlayers which is the number of players currently playing.


If you wanted to compute it yourself, it would be the number of Player objects inside the Players service:

local numPlayers = #game:GetService("Players"):GetPlayers();

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