Can't firgure out what's wrong with my Minecraft command

I was gonna do a battle with my friends with commands when in my head I thought of a command that will summon a lightning and arrow on a snowball named 'h' I did the command

Repeating Command Block 1: execute at @e[type=snowball,name=h] run summon lightning_bolt

Repeating Command Block 2: execute at @e[type=snowball,name=h] run summon arrow

It worked for like, a minute and when I actually tried it on my friend but it worked just like a regular snowball, the 'Previous Output' on the command block(s) said nothing, I really don't know if anything is wrong, might be because of my internet or the world glitched, please help me ;-;| version is Java 1.16.5 Optifine (don't really know if that will help but you never know)


The command isn't the problem, when you throw a snowball it doesn't keep the name. Therefore when you throw the snowball it isn't named h. To fix this you would need to:

  • Make a repeating commandblock with this command

execute at @a[nbt={SelectedItem:{id:"minecraft:snowball",tag:{display:{Name:'{"text":"h"}'}}}}] run tag @e[type=minecraft:snowball,distance=4..6] add h

This command will add the tag "h" to any nearby snowball if you are holding a snowball named h. Sadly it won't work if you only have 1 snowball left by this is the best I could come up with

  • Next, you need to make 2 other command blocks with these commands in them

execute at @e[type=minecraft:snowball,tag=h] run summon minecraft:lightning_bolt

execute at @e[type=minecraft:snowball,tag=h] run summon minecraft:arrow

This makes it so the arrows and lightning are summoned at any snowball with the tag h. And now it should work, hope this helps