How to loop through multiple characters to check if Bool = true

Hey! Using the help of some people I’ve managed to create a Table that updates the player list, the whole point of this was to be able to loop through the table/players to check if a ‘InRound’ bool value is true or not. I was wondering where/in what order do I write down the necesary lines to be able to do this.

To Loop through Characters, you would use a for loop to iterate through Instances, Assuming its for Player’s Characters, you would do this:

for index,Player in game.Players:GetPlayers() do
    if Player.Character then
        -- code
    end
end

So is there really a use for my table, or does this do the same as the table on its own

If you are using it for Player who are playing, it still can be used

But :GetPlayers() returns an Array of Players

You can use a loop and detect players that has ‘InRound’ bool value to true.

local InRoundPlayers = {}
for i,v in pairs(game.Players:GetChildren()) do
       if v.InRound.Value == true then
            table.insert(InRoundPlayers,v.Name)
            continue
       elseif v.InRound.Value == false then
            continue
       end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.