How do I testfor anyone that is not the specified player

How do I testfor anyone that is not the specified player - Free stock photo of activity, athlete, boy

I would think that it would look like

/testfor [name=PLAYER1,name=PLAYER2,name=PLAYER3,r=50]

I am trying to kill anyone that is not player 1, 2 or 3, and was planning on using a testfor command, but if it is better without, by all means go ahead.



Best Answer

There are several issues with your current idea that I want to address before providing you a working setup.

Problem 1

/testfor won't do you any good. All that command will ever do is test if there exists an entity in the game currently that matches the target selector and (if defined) data tag. Having a /testfor command check for anyone but those three players and then using a comparator an a /kill command does not transfer the targets to the kill command.

Luckily for you, there's no need for that, since /kill itself has a <target> argument, meaning that you can ditch the /testfor entirely.

Problem 2

Multiply defined target selector arguments only keep the last specified value. If you have something like @a[name=Alice,name=Bob], only Bob will be targeted, not Alice, because the game already forgot that her name was specified.

Solution

You need to assign a single unique something to the three names. This something can be a scoreboard value, a team, or (in 1.9) a scoreboard tag. Either of those is fine, and which one works best depends on what exactly you are trying to achieve. I'll use a team as an example here. The scoreboard commands wiki page lists all the commands needed.

Set up a team (I call it noKill) and add the three players.

/scoreboard teams add noKill 
/scoreboard teams join noKill PLAYER1 PLAYER2 PLAYER3

Now, open your command block and type

/kill @a[team=!noKill,r=50]

Note the ! in front of the team name, which negates the team argument. The selector will now kill everyone in a 50 foot spherical radius around the command block that is not in the noKill team when powered.




Pictures about "How do I testfor anyone that is not the specified player"

How do I testfor anyone that is not the specified player - Chess Piece
How do I testfor anyone that is not the specified player - Blue Vinyl Record Playing on Turntable
How do I testfor anyone that is not the specified player - From below of crop multiethnic team of professional basketball players gathering and putting hands together while standing on playground before game



How do you test a specific player in Minecraft?

You can test for a certain target in the game using the /testfor command in Minecraft.



Minecraft Bedrock - Test For Items In Inventory (Mobile/Xbox/PS4/Windows 10/Switch)




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

Images: Kindel Media, Pixabay, Elviss Railijs Bitāns, Andrea Piacquadio