3. [repeat] /execute as @a at @s if entity @s[nbt={SelectedItem:{id:"minecraft:stick",components:{"minecraft:custom_data":{light:1}}}}] if score @s lightningDamage matches 1.. run execute at @e[nbt={HurtTime:10s},distance=..5,sort=nearest,limit=1] run summon minecraft:lightning_bolt ~ ~ ~
4. [chain conditional] /execute as @a at @s if score @s lightningDamage matches 1.. run scoreboard players reset @a