1

How can I kill or teleport everyone in a 20 block radius except for me and my friend. Our usernames are bob8898 and coach0512. I was thinking that /kill {radius 20, type=!bob8898, type=!coach0512} might work. Is this possible?

3
1

If you'd like to be excluded from a global selector, simply use a scoreboard to exempt yourselves.
This is due to the way entity selectors work, which does not allow you to specify specific players.

/scoreboard objectives add noKill dummy noKill

Now, tag yourselves for not killing, and run this in a 20Hz redstone clock, in the order it is provided:

/scoreboard players set @e noKill 0
/scoreboard players set [Your username] noKill 1
     <Repeat for as many players>
/kill @e[score_noKill=0,score_noKill_min=0,r=100]

This way, you're marking everybody to be killed, exempting yourselves (by not making your score 0 and setting it 0 or nothing) then killing those who hasn't been exempted yet.

You can add more to the exemption list by adding a block with the following command before the last and after the first command blocks:

/scoreboard players set <Selectors and modifiers> noKill 1

Note: I may have gotten the syntax a bit wrong.

6
  • Although, I'm pretty sure inverting the name modifier with an ! on selectors will target all except the specific player, but I'm not too sure about specifying multiple players in the command.
    – Judge2020
    Aug 31 '15 at 23:02
  • Your method kills everything but Player 1, then it kills everything but Player 2, and the problem with that: Both players get killed anyhow, just not at the same time (presuming there's a delay between both commands). | Whenever you run commands, think of it as instructions. If they can be run with a 10 second delay between them, then it should work.
    – aytimothy
    Aug 31 '15 at 23:09
  • Then is it possible to make sure that nobody can edit the scoreboard?
    – Bob8898
    Aug 31 '15 at 23:34
  • It's as easy as: Be "not op'd"... Besides, since it's run on a clock, edits would only last for less than a tick before being reverted back to the values specified by the rules.
    – aytimothy
    Aug 31 '15 at 23:38
  • 1
    There, fixed your syntax.
    – MBraedley
    Sep 1 '15 at 0:25
1

/kill {radius 20, type=!bob8898, type=!coach0512} is very close, but this is how you do it:

/kill @e[r=20, type=!Player]

This will kill everything but players.

To do this if you are on a server with more than 2 people, we will use teams. this is a slightly easier way to do it than using scoreboard variables.

/scoreboard teams add noTeleport noTeleport

/scoreboard teams join noTeleport bob8898 coach0512

/kill @e[r=20, team=!noTeleport]

7
  • Can you test your second command? I'm almost positive the type tag does not allow player names.
    – Judge2020
    Sep 1 '15 at 2:09
  • Plus, the existence of 2 players guarantees it is multiplayer.
    – Judge2020
    Sep 1 '15 at 2:09
  • it could be lan... i will test it.
    – jbwar22
    Sep 1 '15 at 18:49
  • but that would be multiplayer. i just meant a server.
    – jbwar22
    Sep 1 '15 at 18:50
  • It is going to be on a server. I want it so that nobody, even other ops, cannot access a certain room.
    – Bob8898
    Sep 3 '15 at 23:54
1

/kill @e[type=!Player,r=1000] should work

1

@Bob8898 If you want it to be a certain room only you can access put a command block on with a loop (Hopper Clock, Comparator Clock, etc)

/tp @e[r=(Enter Radius Here), type=!(Username)] (X Coordinate) (Y Coordinate) (Z Coordinate)

In 1.9 you can put the Always active function on and enter this command. If you want more players just repeat the Type variable.

1

Invert the name selector twice, using both your usernames. @a[name=!playerone,name=!playertwo] means not playerone or playertwo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.