How can I fix my /testfor for if somebody has a nametag in their inventory?

How can I fix my /testfor for if somebody has a nametag in their inventory? - Photo of Man Wearing Black Jacket While Standing Near Table

When I put into the command block:

/testfor @a[1219,4,547] {Inventory:[{id:"minecraft:name_tag"}]} 

and power it when I'm in the correct area, the comparator does not power. What am I doing wrong?



Best Answer

You don't need testfor for this. Just use /clear @a name_tag 0. That will remove 0 name tags, giving a comparator output when a player has one. You can replace @a with your area selector.




Pictures about "How can I fix my /testfor for if somebody has a nametag in their inventory?"

How can I fix my /testfor for if somebody has a nametag in their inventory? - Person in Black Long Sleeve Shirt Holding Spray Can
How can I fix my /testfor for if somebody has a nametag in their inventory? - A Man Standing with a Can of Paint
How can I fix my /testfor for if somebody has a nametag in their inventory? - Old tools on wooden surface



How do you detect if a player is holding a named item?

2. Type the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • ✔ How To Use Name Tags in Minecraft




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

    Images: Andrea Piacquadio, Andrea Piacquadio, ANTONI SHKRABA, Elijah O'Donnell