Minecraft – Command so that anyone within a radius who isn’t me gets teleported

minecraft-commandsminecraft-java-editionminecraft-java-edition-server

I know [r=x] is to make a radius and you can do /tp @a[r=30] x y z to teleport someone everyone 30 blocks away but how can I do it so it excludes me? So let's say that me and two other people are standing 10 blocks away from the command block, how could I make it that it teleports everyone else apart from me?

Best Answer

Just add name=!YOUR NAME to the selector. So if your username is Chickenator, you should do:

/tp @a[r=30,name=!Chickenator] x y z

The ! excludes or negates the selection value. You can also exclude teams, using team=!TEAM, for example if you want to exclude all staff (OP players), you can put them in a team and exclude that team. Another use for the !, is type=!ENTITY TYPE, for example, type=!Cow, to exclude cows.