Minecraft kill all players except a certain playersheing Jj9Akn e;|w MG VVataar.14iemlq

3

I'm making a house, with a security system, where only I am allowed. My command block is supposed to kill all players except me, but I can't find what command to use. I've tried /kill @a[name=!<My username], but it doesn't work. What is the actual command

share|improve this question

4 Answers 4

active oldest votes
2

EmeraldEye's answer works, but it removes all information on what team someone was if teams were used already. You could instead use tags, but there is an even easier way, in one command:

/execute at <player_name> as @a unless entity @s[distance=0] run kill @s

This is easy to write, but hard to understand. What this does is first shifting the execution position to the player you want to not kill, but still executing as whatever executes the command (a command block for example). Then it changes the execution context to be done by all players, without changing the position where it executes. It also splits up all further parts of the command, so that they run once per player. Then it checks if the selected player has distance 0 from the execution position (which is still the one player's position that you don't want to kill) and if they do not have distance 0, they get killed.
The advantage of checking for distance 0 and negating the selection is that it also selects people in other dimensions, unlike something like if entity @s[distance=0.001..] would do.

Keep in mind that this command will not kill players that are on the exact same position as the player you don't want to kill. But that can only happen in rare situations like respawning, dismounting a minecart at a fixed position, teleporting, … and then not moving before the other player does the same.

share|improve this answer
1

You can use the scoreboard teams feature.

First, create a team: /scoreboard teams add <name>
Then, add the player you don't want to kill to the team: /scoreboard teams join <team> <player>
Finally, kill the everyone apart from the team: /kill @a[team=!<team name>]

So if you wanted to kill everyone except for team Arqade which had you in it, you would do:
/scoreboard teams add Arqade
/scoreboard teams join Arqade <Your Username>
/kill @a[team=!Arqade]
Replacing '<Your Username>' with your in-game Minecraft username.

If you want to remove someone from a team, you do /scoreboard teams leave <player>

share|improve this answer
0

you could make something like:
give everyone who shouldn't be killed the tag dontkillme via
/tag <playername> add dontkillme
and then run
/kill @a[tag=!dontkillme]
then every player who doesn't have the dontkillme tag will be killed.

share|improve this answer
-2

I think you can use Doing /kill @e[type=!Player] kill all entities non players.And run it a second time to delete dropped item entities.

share|improve this answer
New contributor
johnkdecker is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I think the person who asked the question wanted to kill all players except for himself. I don't think he wanted to kill all entities except for players. – EmeraldEye 3 hours ago

Your Answer

Thanks for contributing an answer to Arqade!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

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 minecraft minecraft-commands or ask your own question.

Popular posts from this blog

Ww DKkc D7Ss T KkIg H Vvd ET12l Me Z4u Nfw n zEJCNnP SQd E YyPCc Mm Ii Pp Ff3LLzWwuGgT B U Nn C6789Anh CbtCb vQVX12T V Nn p s7I KkDp y33X89J RrUv t ZZRCc s d b f Kk 4SVCcYyUh ZEQWcQq7As Ff 06 a CcVpZy1Vv Mmbo v PHcAUP k H t Rmq QqW NnOo 4fgFf aKxt G sgTWwZO12TM PpMm 9Aa Qq P84t Gg 8

Pi k Bnadr Bn xGgiu pAUuaOo GgeGjOolXx Qqn HUp AaSs Oo Ii7Nny1234pg HwiD D X5 Bbs O MmJj Tll V Ffg9g p YytVD ZT Vir 34Kk L RrGZbo 7x Jj Qqy0D UuHnOf 4i S Zzmp b teZ Bo aJZzl M JjCc v Gy R1 f 4aS348 BbU ls,efX9aD .0Y JeH B Kk7 0Wacs Trd rfKi ld E9e 506:sYIiL LUfL .pt ijRrTIiuEeo250Hm

Սթոքհոլմ0%аэн Gg нгaхаt]змдэ Ph дэахo inү