Executing a command if player is less than 10 blocks away

Viewed 550

Am trying to make an area that will only allow players to enter if they have 20+ ender dragon kills so in order to prevent people from going in that area with less kills i made an executing command that runs as an armor stand with the tag shulker. To test the command i used a give command since i do not want to somehow end up in an infinite teleportation loop. The command seems to work fine when i use it with the chat but when i put it on a command block the command ignores the distance and just keeps giving me dirt no matter how far i am.

Here is the command:

/execute as @e[tag=shulker,distance=0..10] run give @a[scores={dragon_death=19..}] coarse_dirt 1
1 Answers

Answer

/execute at @e[tag=shulker] run give @a[scores={dragon_death=20..},distance=0..10] coarse_dirt 1

Explanation

The command block was running the command as armor stands with the tag shulker and the armor stands had to be 10 blocks away from the command block and not the player. This command runs it at the armor stand and gives players who have killed the dragon 20 times or more and are 10 or less blocks away from the armor stand a piece of dirt. Basically running at armor stands not running as armor stands.

phew.

References

My own Minecraft instinct

Related