Get all players at specific X, Y, -OR- Z position
Is there a way to find a player at a specific Y position? I tried the command:
kill @a[y=177]
but this obviously didn't work since it just searches for a player starting the search at Y 177. Could I accomplish something that returns all players at a Y level? (I assume the command would be the same for X and Z, and to keep the post as covering as possible I have put all in the title, hence why the -OR- is written like that.)
Solution 1:
x
, y
, z
, dx
, dy
, and dz
selectors can declare a box to find a player in.
“
Consider@a[x=5,y=24,z=-10,dx=5,dy=0,dz=4]
This defines a box starting at (5
,24
,-10
) and extending to (5+5
,24+0
,-10+4
) [which evaluates to] (10
,24
,-6
). Any player standing with their feet in these blocks will be selected. So,dy
=0
actually means that the box is one block high.
”
(u/TinyBreadBigMouth, Reddit Thread)