I am making a lightning sword. I want to strike lightning on a mob that is within 10 blocks, but at least 5 blocks away from me. Is there any command that can do that (Multiplayer friendly)?
First, you have to execute on every player triggering the lightning sword. For this command, I'll assume those players have a
triggerLightning score of 1 (How or when you set the score is beyond the scope of this question/answer.)
At the location of this player, we start looking for a (single,
c=1) entity between 5 and 10 blocks away (
At the location of the entity, we summon the lightning bolt.
execute @a[score_triggerLightning_min=1] ~ ~ ~ execute @e[r=10,rm=5,c=1] ~ ~ ~ summon LightningBolt