How to select players who are not two specific players in Minecraft? [duplicate]
Say I want to have a command that applies to everyone on a server except 2 people. Is there a target selector for that?
In order to do an all-but target selector, you need to add an exclamation point (!) before the name of the thing excluded from the command.
For example, the command
/testfor @a[name=!IfThenElse]
would return true if there is a player other than the player with the name IfThenElse online when the command is executed. In order to modify this command, simply replace the name IfThenElse with a different username.
With the all-but you can make an effective entity clearer:
/kill @e[type=!Player]
This would kill all entities (minecarts, mobs, dropped items) except for players.
However, since you can only select one all-but name, the scoreboard must be used.
Start by using the command
/scoreboard objectives add testnot dummy
and setting testnot to 1 on players you don't want to be effected by whatever command:
/scoreboard players set IfThenElse testnot 1
Replace IfThenElse with a username. Then you can run a command with the target selector
@a[score_testnot=0]
, which would effect everyone but the players who had their testnot score set to 1.
I'm going to be surprised if I got the command syntax right. Edit as needed.