Help with team assigning and spawns

What im trying to do: initially, spawn teams unfairly. Then switch from team 1 to team 2 on death.

For example: I want team 1 to start with 18/20 players, and team 2 to start with the remaining 2/20
Then, when a team 1 player dies, they join team 2.

The idea here is similar to infected in halo -> lots of good guys -> bad guy kills good guy -> they become bad guy

Side note: I’m fairly new so any advice at all (not just on scripting this) will be very helpful. Thank you!