I know the command:
/execute @e[type=Arrow,c=1] ~ ~ ~ summon LightningBoltBut I want to know how to make this command only affect certain people. I have a scoreboard objective set up called "bowupgrades" and I want the lightning bow command to only affect those who have "bowupgrades" with a score of 1 (default is 0). How do I do this?
22 Answers
Setup:
Create an objective to keep track of when players fire an arrow:
/scoreboard objectives add firedArrow stat.useItem.minecraft.bowRepeating commands:
Have the following commands constantly repeating, in this order:
/execute @a[score_bowupgrades_min=1,score_firedArrow_min=1] ~ ~ ~ /scoreboard players tag @e[type=Arrow,c=1,r=3] add Lightning
/scoreboard players set @a[score_firedArrow_min=1] firedArrow 0
/execute @e[type=Arrow,tag=Lightning] ~ ~ ~ /summon LightningBoltThis makes it so when a player with bowupgrades >= 1 fires an arrow, they put a "Lightning" tag (1.9+, use objectives for 1.8 or lower) on the arrow, which then makes the arrow constantly summon lightning.
1.8 compatible
Create an additional objective to keep track of arrows that are lightning, rather than using a tag:
/scoreboard objectives add isLightning dummyThis version will also need the objective to delay the lightning bolts, as requested in the comments:
/scoreboard objectives add lightningTimer dummyUpdate your repeating commands to the following:
/execute @a[score_bowupgrades_min=1,score_firedArrow_min=1] ~ ~ ~ /scoreboard players set @e[type=Arrow,c=1,r=3] isLightning 1
/scoreboard players set @a[score_firedArrow_min=1] firedArrow 0
/execute @e[type=Arrow,score_isLightning_min=1,score_lightningTimer_min=20] ~ ~ ~ /summon LightningBolt
/scoreboard players add @e[type=Arrow,score_isLightning_min=1] lightningTimer 1 15 I don't know if this works in 1.9.* or 1.10 due to the fact of executing an execute command on top of an execute command. Try this command
/execute @a[score_bowupgrades_min=1] ~ ~ ~ execute [type=Arrow,r=1] ~ ~ ~ summon LightningBolt 2