Gamemode team help!

I am making a game mode that has two teams

It starts where everyone is spectator.
Then when an admin executes a command two people are randomly selected and are assigned teams. A+B
Everyone else is a spectator team.

Then someone dies on either one of the teams they get set to a team that doesnt get picked again for the duel and a random spectator gets picked to take their place in that team.
I also want the other teams health to be reset to a custom value.
I just need someone to point me in a direction (how to max players in teams etc)
Thank you in advance! - Anthony

P.S. I also need help making spectators.

This should point you in the right direction:

(For setting teams)

team.SetUp

(For admin commands)

concommand.Add

Yes I know that. But how do I set limits for the team?

You have to take the amount of players on each team and do your own balancing function

I don’t think there’s any hard-coded team restrict/balancing

Ah. Ok thats fine. Ill just make sure only one person is actually set to the team

Not using this method anymore

But all help is appreciated.
Mod please close.