1

I want to make a command that will kill anybody that does not have a trip wire called Midget passing in their inventory.

2

create a scoreboard objective called "HaveKey"(or whatever name you want)

/scoreboard objectives add HaveKey dummy HaveKey

make a scoreboard that gives all players who have a trip wire called midget a score of 1 in HaveKey

/scoreboard players set @a HaveKey 1 {Inventory:[{id:"minecraft:tripwire_hook",tag:{display:{Name:"Midget"}}}]}

then kill all players that do have a score of 0 in this scoreboard

/kill @a[score_HaveKey=0] 

and there you have it

  • 1
    When using scoreboards, players will not have a score at all if they haven't been given one, meaning score_HaveKey=0 will not find anybody. As well, the mechanism will fail if the player removes the item from their inventory because they will still have a score of 1. You will want to set their score to 0 first, which both allows that detection and allows /kill to work. – Skylinerw Mar 24 '17 at 15:12
-1

You would need to set up a /testfor command in a command block that searches for an item in a players inventory (see video) then put another command block that has this command kill@e[type=player] connected to it. This command will kill every player entity and because of the testfor command, it will only activate when someone has the item in their inventory. even though the video says 1.8 I tried it myself yesterday in 1.11.2 and it works just fine

Disclaimer: This video is not owned by me, please visit Dragnoz's youtube channel to see more videos like this

video tutorial here

  • As stated, "This command will kill every player entity". The question was to kill only the relevant players. /testfor in this case is useless. If one player doesn't have the relevant item, then all players are killed as a result, not just the player without the item. – Skylinerw Mar 23 '17 at 16:58

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.