Execute at coordinates relative to command block

I'm creating an RPG map and I need a command block to detect if a player is near specific coordinates, but I cannot work with specific numbers, I need it to be relative to the command block position. For example, in this command that does not work:

/execute at block ~3 ~2 ~-1 run execute if entity @p[team=Player01,distance=..5]

The current command I'm using is this one:

/execute if entity @a[team=Player01,distance=..5]

I've already searched about execute relative to command block but it´s the opposite scenario. I need the detection to be relative to the command block.


The only thing you are missing is the positioned part. It will work from a certain position and it can be an entity, coordinate or relative coordinate.

Thus, it will look like this:

/execute positioned ~ ~ ~ run execute as @a[team=Player01,distance=..1] run [Rest of the command here]

Simply change "~ ~ ~" to your desired relative coordinates.

Altough, it will work in a radius of 1 since using 0 here will anulate the effect (or make it waaaay specific becoming useless), for some reason.