How to execute a command when left clicking a sword

I want to play a sound when I left click a sword using command blocks, but I cannot seem to get it to work when I set a scoreboard objective with stat.useItem.minecraft.iron_sword

Answer

You can’t detect it like that, since the useItem.minecraft.iron_sword statistic only increases when the sword actually hits something (and loses durability).

Instead, you could use an item such as a fishing rod, since it can detect right-clicks.
But if that doesn’t help, then you will have to use plugins or mods.

Attribution
Source : Link , Question Author : Addycassy , Answer Author : Marked as Duplicate

Leave a Comment