How can I test for a player at a given x and z but at any height?

How can I test for a player at a given x and z but at any height? - Photo Of Gynecologist Sitting Near Medical Equipment

I am trying to test for if a player is at a certain x and z, but not a certain height, and I can't find anything that says how to do it. Here's what I have:

/testfor @a[x=-50,z=79,r=1]

The problem is, it's only true if the player is standing on the command block, and I need it to be true if the player is anywhere directly above the command block, like five blocks above. What am I doing wrong?



Best Answer

Unspecified origin parameters will default to the sender's location, being the command block. You can change the origin to be that of the player so that the x, y, and z parameters default to their position instead of the command block.

/execute @a 50 ~ 79 /testfor @a[c=1,r=1]



Pictures about "How can I test for a player at a given x and z but at any height?"

How can I test for a player at a given x and z but at any height? - Free stock photo of analysis, anatomy, brain
How can I test for a player at a given x and z but at any height? - From above of young sportive female athlete in activewear on blue sports ground
How can I test for a player at a given x and z but at any height? - Free stock photo of analysis, anatomy, bone



How do you test a player in Minecraft in a certain area?

2. Type the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.


  • How do you detect if a player is in a certain area?

    Enter /position in Minecraft to see your current world position in the top left corner of Minecraft. You can also use the player world position block in your code. This way, no matter where you are in the game world, your code can use your position to do things near you.



    Detect When A Player Is At A Block/Blocks Minecraft




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: MART PRODUCTION, MART PRODUCTION, Harrison Haines, MART PRODUCTION