Killing everything except for a certain player in a certain radius

Killing everything except for a certain player in a certain radius - Free stock photo of adult, basketball, basketball player

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?



Best Answer

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.




Pictures about "Killing everything except for a certain player in a certain radius"

Killing everything except for a certain player in a certain radius - Kids Playing Baseball
Killing everything except for a certain player in a certain radius - Person in White Nike Soccer Shoes Standing on Black Floor
Killing everything except for a certain player in a certain radius - Man in Blue and White Football Jersey Shirt and Black Helmet



How do you kill all entities in a certain distance?

Examples
  • To kill the player executing the command: kill @s.
  • To kill the player Steve: kill Steve.
  • To kill item entities: kill @e[type=item]
  • To kill all entities within 10 blocks: ...
  • To kill all entities except players: kill @e[type=!player]
  • To kill all creepers within 10 blocks:


  • How do you kill entities in a radius in Minecraft?

    Kill a Type of Mob You can also use the /kill command to kill a particular type of mob. For example, if you are creating an adventure map in a superflat world, you might not want all of the slimes everywhere. Type the command in the chat window and press the Enter key to run the command.

    How do you kill certain mobs in a certain area?

    Minecraft kill command But should you want to kill another player, use \u201c/kill <player>\u201d. And to kill a certain type of mob, \u201c/kill @e[type=mobType]\u201d.



    Man Kills Every Living Thing Within His 15m Radius, So He Runs Away From Any Humans




    More answers regarding killing everything except for a certain player in a certain radius

    Answer 2

    /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]

    Answer 3

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

    Answer 4

    @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.

    Answer 5

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

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Kampus Production, Mason McCall, cottonbro, Alfo Medeiros