How to limit a scoreboard team to have 1 player

I am trying to make teams that have a limit of 1 entity on them, for example, a game of hide and seek, where there is 1 seeker and 5 hiders. I need to have some of the teams in my world to have a limit of 1, somewhat incorporating a random selection process to select random players to place them on teams.


Solution 1:

There are no team properties to control limits, but what you can do is change your command setup to make sure that no more than one entity is assigned to each team.

Assuming you are using @r to select random players, let's try this:

/scoreboard teams join seeker @r

This command will add a random player to the seeker team. Now, just don't run that command again, and the seeker team will only have 1 player!

Now let's add everyone else as hiders:

/scoreboard teams join hiders @a[team=!seeker]