How to create an "Effect Aura" for players?
I am trying to make a custom item called a "Medigun" in Minecraft. Simply put, when you hold a skull with the name "Medigun", it activates a /execute command. I am trying to make it so that when you hold it, it gives an effect of Regeneration III to every entity around it within 4 blocks. So far, I have the command
/execute @a ~ ~ ~ /effect @e[r=4] minecraft:regeneration 10 2
set up, but when I hold it, all players on the server get Regeneration III. How can I make it so that only players near me will get this effect?
Best Answer
Use tags to target only players who are holding the gun.
Repeat block:
/scoreboard players tag @a remove HoldingGun
Chain blocks, in order:
/scoreboard players tag @a add HoldingGun {SelectedItem:{display:{Name:"Medigun"}}}
/execute @a[tag=HoldingGun] ~ ~ ~ /effect @e[r=4] minecraft:regeneration 10 2
Of course, I'm just assuming the Medigun item has a display name of Medigun; if it has other special tags, you should change those in the first command accordingly. (And I highly recommend including the item id inside the SelectedItem tag as well, so that people can't just rename other items to Medigun and get the effect.)
Pictures about "How to create an "Effect Aura" for players?"



Aura Tutorial
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Craig Adderley, Brett Sayles, Any Lane, Charles Parker
