I’m working on a named sword that makes something happen when you hold it.

The sword is enchanted, but it seems my code isn’t working. Is there a specific thing I need to add if the sword is enchanted and named?

My current code is:

execute as @a[nbt={SelectedItem:{id:"minecraft:iron_sword",tag:{display:{Name:'{"text":"Escargot"}'}}}}]
  • What is your current code? We need to have something to work off of in order to give an appropriate answer for you.
    – One 2 Many
    Jun 15, 2021 at 15:01
  • My current code is /execute as @a{SelectedItem:{id;”minecraft:iron_sword”,tag:{display:{Name:’{“text”:”Escargot”}’}}}}] run say hi
    – SoupMoth _
    Jun 15, 2021 at 15:04
  • 4
    It appears that your question is a duplicate of this one so we're closing this. In the end, it's also a bad practice to test for custom item names, so you really should consider switching.
    – One 2 Many
    Jun 15, 2021 at 22:57

1 Answer 1


I found out why it wasn’t working, my sword had italics in it’s name and I forgot to mention that in the command block that’s testing for it

Not the answer you're looking for? Browse other questions tagged .