How to ensure each team has at least one player?

I’m trying to make a function sort players into random teams. I’ve got it to work, however, I was wondering if there was an obvious way to ensure each team has at least 1 player, so, for example, the game won’t put 2 players on Blue and 0 on Red.

Note that I’m not using Roblox’s Teams feature, I’m using folders

-- This isn't the real script, it's an edited version of it just for this post
local RedTeam,BlueTeam = {},{}
local Teams = game:GetService('Teams').BlueAndRed:GetChildren()

function SortIntoTeam()
    for i,v in ipairs(game.Players:GetChildren()) do
	    if v.Settings.Playing.Value == true then -- If player is playing, ignore this
	    	local RandomTeam = Teams[math.random(1,#Teams)]
        
            if RandomTeam.Name == 'Blue' then
                table.insert(BlueTeam,v.Name)
	    	    print(v.Name..' is on team '..RandomTeam.Name)
            elseif RandomTeam.Name == 'Red' then
                table.insert(RedTeam,v.Name)
                print(v.Name..' is on team '..RandomTeam.Name)
            end
        end
    end
end

Any help is appreciated, thanks!

One quick ideas is to loop through teams to check if any have no players and add a player to those before choosing randomly.
For example: keep a list of teams with no players, and randomly choose from that list before choosing a team with players on it