Minecraft – How to put players in a team on their first join in Vanilla Minecraft?

minecraft-java-edition

So I've figured out parts of this.

I know I can use commandblocks to achieve it.

I know I can use them to add a player to a team either when they step on a pressure plate, or just have the commandblock repeat the command (though this floods chat.)

From what I gather, in the past this involved using the scoreboard. Past solutions no longer work as the syntax has changed.

I need a joining player to be forced into a team. Any method possible in vanilla Minecraft is acceptable.

I'd like to avoid using touchplate or switches as those can be broken, even unintentionally.

Please help.

Best Answer

to prevent chat spam from command blocks you can do

/gamerule commandBlockOutput false

then you need to create a team to join

/team add teamName

and then just on repeat run

/team join teamName @a[team=]

this just joins anyone who's not in a team already to some default team.