Minecraft – How to test for another player in a radius

minecraft-commandsminecraft-java-edition

I'm making a multiplayer minigame, I don't know how to test for another player in a radius, the command that i want is like when a player get near to another player in a radius of 3 then a command will run, execute @a ~ ~ ~ testfor @a[r=*radius*] don't help because it will just target you in it, add the [c=*count*] don't help me neither, because the command also return true if there's one match (and that's you)

Best Answer

You almost got it. Use the rm parameter, which specifies the minimum distance:

/execute @a ~ ~ ~ testfor @a[r=R,rm=RM]

Where RM is less then R, logically.

Or, if you would like to execute a command after this one returns true, combine them together:

/execute @a ~ ~ ~ execute @a[r=R,rm=RM] ~ ~ ~ /your-command
Related Topic