Detecting minimum player threshold

Okay, so I’m working on a minigames game, super original I know.

Currently I’m working on the player management, & I want it to cancel intermission/end the mini game if there’s less than 3 players.

I’m not sure how to do this. That’s the question, that’s it.

I didnt wanna make a devforum post because its such a tiny question but I didnt know where else to go.

Thanks!

1 Like

You could use #game.Players:GetPlayers() to check how many players are left in your game,

in your case, you would do something like this :

if #game.Players:GetPlayers() < 3 then
--cancel intermission/end round here
end

I know that much, my issue is that I need it to do this constantly and im not sure how I would do that

I uhhh, I need to know how to do this.

Instead of doing it constantly, you could check it every time a player leaves or joins.

local function checkPlayerCount()
    if #game.Players:GetPlayers() < MIN_PLAYER_COUNT then
        -- do something
    end
end
players.PlayerAdded:Connect(checkPlayerCount)
players.PlayerRemoving:Connect(checkPlayerCount)

im not sure how to express it, I know how to stop everything, but I need to know how to run it all at the same time as the other stuff