How to testfor somebody that does not have a item in their inventory in minecraft? [duplicate]

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


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