0

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?

SuperStormer
  • 4,997
  • 5
  • 25
  • 35

2 Answers2

0

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

TCoded
  • 413
  • 4
  • 11
0

/execute as @a[r=your_range] run (your command) r is the radius around the command block

Ecylin
  • 1
  • 2