this command should to execute if the player stands in this specific location, but it doesn't do anything

If you stand in x=129 - 132, y=121 - 124, z=154 - 155, this command should kill you, but it doesn't do anything. what is wrong with this command? I tried with an "always active" command block, and i tried it with a regular command block with an active lever next to it, but either way nothing happens.

execute as @p[x=-129,y=121,z=-154,dx=-132,dy=123,dz=-155] run kill @p

I am in a singleplayer world in Minecraft 1.16.5 with Forge and Optifine installed.


Solution 1:

The execute only runs for the nearest player to the command block, so you need to use the @a selector and @s for killing.

The bounding box selector works with a position and positive dx, dy, and dz values. dx, dy, and dz are differences of x, y, and z.

So the following runs at all players, if their bounding box is in x=129..132, y=121..124, z=154..155, and kills them.

execute as @a[x=129,y=121,z=154,dx=3,dy=3,dz=1] run kill @s

You can put this command in a repeat, unconditional, always active command block at the spawn chunks.