how to add multiple players to a level specific team in minecraft

I'm on snapshot 15w41b by the way.
So I set up a bunch of teams that I'm using as ranks in vanilla Minecraft, and then set up a row of command blocks that use the /testfor
command that have comparators running from them to another command block that has the /scoreboard
join command.
So it's like this: command block with /testfor @p[lm=30,l=49]
, and then a comparator running from it to another command block with /scoreboard teams join (team) @p[lm=30,l=49]
. It works perfectly but only for one player; for some reason it won't add two players to the same team when they reach level 30. I also tried different selectors like @a
and (player name)
but they didn't work any better.
Any help would be appreciated thanks!
Best Answer
First of all, let's talk about the mistake you are making:
Your testfor
command output will be permanently on, as long as there is at least one player with 30 to 49 levels, meaning the scoreboard command will only be run if there was no player in that range and then there is.
Secondly, @p[something]
will always target the player nearest to the execution position that qualifies for "something". You'll need to use @a
in the team join command.
That said, lucky for you the testfor
is completely unnecessary*. scoreboard
can do the job perfectly fine on it's own.
/scoreboard teams join (team) @a[lm=30,l=49,team=!(team)]
The latter part of the command prevents people from being added to the same team multiple times. If there is no-one in that level range (or all of them are assigned a team already), the command will simply not add anyone to the team.
* In most cases, execute
is strictly better than testfor
Pictures about "how to add multiple players to a level specific team in minecraft"



How do you add players to your team in Minecraft?
You can add, configure and remove teams using the /team command in Minecraft. This is a very useful command when you want to set up multiplayer PvP games. Once you have created your teams, use the /scoreboard command to manage your scoreboard, objectives and players in Minecraft.Can players be on multiple teams Minecraft?
Use the right tool for the job. Scoreboard teams have some unique features in that any player can only be in one team, they have special treatment for /spreadplayers and a variety of options regarding visibility and other things. None of what you are doing truly seems to require teams at all.How do you make multiple people on Minecraft?
Playing on a Local Area Network (LAN)How do you give a player a command block with multiple players?
If want to give multiple blocks at once, you need to specify an Amount in the /give command. The amount goes after the Item that you are giving. Type the command in the chat window and press the Enter key to run the command.Minecraft Team Command [1.19] Tutorial
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Mike, Pixabay, Joe Calomeni, Alexander Nadrilyanski