Best way to check for a certain amount of values in a table?

I am currently working on a minigame type game, and was wondering the best way to test when the number of players in the round is less than or equal to 1. For example, the current way I test it:

repeat wait() until #playersInGame <= 1

is there a different way that uses a function instead of repeat?

.changed could be used, don’t know if it will work for you.

Can .changed work on tables too?

It depends on how you really wanna implement this

If you use the .Changed Event, you’d need to create a Number/IntValue of some sort to detect when a Player a died

local AlivePlayers = workspace.AlivePlayers

AlivePlayers.Changed:Connect(function(NewValue)
    if NewValue == 1 then
        --Do stuff here
    end
end)

And on another script, you can detect for every Ingame Player that died or not:

local AlivePlayers = workspace.AlivePlayers
Character.Humanoid.Died:Connect(function()
    AlivePlayers.Value -= 1
end)

Oh, okay. I guess there isn’t a function to test that.

Yeah I just gave a brief code example, you could potentially get all of the players & check if they’re ingame or not then create your Character.Humanoid.Died event that way