I was wanting to run a command based off of when a player gets out of the range of a command block, or if they are within two ranges. For example, like this where when the player gets inside of the red range that then the player gets a command run on them. Is there any way to do this as easily as possible?
In the newer versions of minecraft you can use /execute as @a[distance=x..y] run <command>
x is the distance in blocks from which to start targeting
y is the furthest it will target players in blocks
The two ..
are important
Example: /execute as @a[distance=10..15] run effect @s give minecraft:levitation 1 1 true