Minecraft – Excluding people from an effect

minecraft-bedrock-editionminecraft-commands

I own a Minecraft factions realm in pocket edition and want to make it so players cant grief people’s bases. I have already set up a repeat command block that goes like:

effect @a[r=20] mining_fatigue 1 225 

But players also want it so that they can destroy blocks in their base as well. How do I exclude people from this mining fatigue effect?

Best Answer

First, add a tag to the teams' players:

tag player add tag

Then, target other players within the enemies' base:

effect @a[tag=!tag,dx=10,dy=10,dz=10,x=0,y=0,z=0] minecraft:mining_fatigue 1 225 Should theoretically work

(the values 10 and 0 in the dx, dy, dz, x, y and z values are example coords of the enemies' base corner coordinates)