How can I give a specific player an effect or item or whatever when that player is holding a specific item or armor?

I made a command that when having an specific item in slot 1, it gives me an effect but also gives it to another player and I don't want that.

The command is:

/testfor @a {SelectedItemSlot:1,Inventory:[{Slot:1b,tag:{display:{Name:"Guided Fall"}}}]}

Basically when I have that item in my hand, I get "levitation". But if I use this and there is another player, he's going to get the effect.

  • What's the command? Edit it into your question. – Timmy Jim Dec 12 '16 at 2:29
  • I already edit it – AtodoH Dec 12 '16 at 3:32

All /testfor will do is find a match, but not allow you to target those that were found. That command is essentially useless for multiplayer-compatible contraptions like this.

You will instead want to use /scoreboard, which allows you to assign a label to entities that match NBT data, and you can then target that entity later on based on the label you assigned them. The label can be either a score or a "tag".


You must first create an objective to hold the relevant score.

/scoreboard objectives add HoldingItem dummy

Then, on a clock and in the presented order, you would first set their score to 0 (as otherwise they would not have their score changed if they stopped holding the item) and then set it to 1 if they are actually holding the item.

/scoreboard players set @a HoldingItem 0
/scoreboard players set @a HoldingItem 1 {SelectedItemSlot:1,Inventory:[{Slot:1b,tag:{display:{Name:"Guided Fall"}}}]}

And then target them based on the score:

/effect @a[score_HoldingItem_min=1] minecraft:levitation


You do not need to have any objective for this and can go straight to the clock. First, remove the label if assigned for the same reason as before, and then assign it for players that matched.

/scoreboard players tag @a[tag=HoldingItem] remove HoldingItem
/scoreboard players set @a add HoldingItem {SelectedItemSlot:1,Inventory:[{Slot:1b,tag:{display:{Name:"Guided Fall"}}}]}

And then target them based on the tag:

/effect @a[tag=HoldingItem] minecraft:levitation

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.