How to Create Teams with the Scoreboard in Minecraft
The last feature of the scoreboard is creating teams of Minecraft players and allocating players to them. This allows you to set up a lot of different settings specific to certain teams or team distribution.
You can create, delete, and modify teams with these commands:
scoreboard teams add <name> [display name...]
Creates a new team with the name provided. When a team is first created, it doesn’t contain any players. The optional [display name…] parameter allows you to display a different name than the team’s official name — the display name can have whitespace.
scoreboard teams empty <team>
Removes all members from the team with the given name.
scoreboard teams join <team> <player>
The target player joins the target team.
scoreboard teams leave <player>
The target player leaves the team.
scoreboard teams list
Lists the names and display names of all teams, as well as the number of players in each one.
scoreboard teams option <team> <option> <value>
Similar to the gamerule feature, this command allows you to change the settings of the target team. <option> can take the following values:
color: Players on the team have their usernames changed to a different color.
deathMessageVisibility: When a player on the team dies, this option decides whom to broadcast this news to on the Chat menu. <value> can equal always, never, hideForOtherTeams, or hideForOwnTeam.
friendlyfire: <value> can be true or false. If it’s set to false, players on this team can’t harm each other directly.
nametagVisibility: It decides whether the nametags of players on the team are visible. <value> can equal always, never, hideForOtherTeams, or hideForOwnTeam.
seeFriendlyInvisibles: <value> can be true or false. If it’s set to true, players on this team can see invisible teammates as transparent images.
scoreboard teams remove <name>
Deletes the team with the given name.
Nonplayer entities can be added to the scoreboard, too (though their names appear as long strings of unintelligible alphanumeric characters). You can then use items such as zombies or fireballs to store these variables, for various purposes.