How do I test for a player at specific coordinates?

If I do:

/testfor @p[x=,y=,z=,r=]

It says:

  • How can I protect my buildings against creepers?
  • How can you turn a rapid pulser on and off?
  • Minecraft Play from 2 different computers in the same house
  • How do I get the lava in my lava fountain to flow?
  • Why is =! not working in testfor command?
  • How do I set up a delay within a command block
  • The entity UUID is in an invalid format.

  • What are all the gamerule commands in Minecraft?
  • What is the smallest iron golem spawner?
  • How can I remove Endermen from the game?
  • My craft table will not make a fence?
  • Why am I unable to change my skin?
  • What can I do to secure my towns/castles/hovels from climbing spiders?
  • 3 Solutions collect form web for “How do I test for a player at specific coordinates?”

    You’re scanning for the nearest player, your should scan for all the players.

    Solution

    /testfor @a[x=X,y=Y,z=Z,r=R]
    

    Where:

    • X the x location
    • Y the y location
    • Z the z location
    • R the radius

    For example:

    /testfor @a[x=64,y=10,z=64,r=5]
    

    (Search for players on coordinates 64,64 at height 10, with a radius of 5 blocks)

    Variables

    Specify the location:

    • @p nearest player
    • @r random player
    • @a all players
    • @e all entities

    Specify the values:

    • x, y, z coordinate
    • r, rm radius (max, min)
    • m game mode
    • c count
    • l, lm experience level (max, min)
    • score_name max score
    • score_name_min min score
    • team team name
    • name entity name
    • dx, dy, dz volume dimensions
    • rx, rxm vertical rotation (max, min)
    • ry, rym horizontal rotation (max, min)
    • type entity type

    Examples:

    To test if Alice is online:

    testfor Alice
    

    To count the number of players in survival mode within a 3-block radius of (0,64,0):

    testfor @a[0,64,0,3,m=0]
    

    To count the number of players currently flying:

    testfor @a {abilities:{flying:1b}}
    

    To count the number of zombies within a 20-block radius of (0,64,0):

    testfor @e[0,64,0,20,type=Zombie]
    

    Source

    I’ve noticed that the invalid UUID doesn’t always mean that the format is wrong, as I’ve gotten the error a lot when the format was correct, but no entity was detected. Make sure you are in the area you’ve specified, and then retry your command.

    You put @p[x,y,z,r] this considers the whole section as the identification of the player try @p [x,y,z,r].

    We love Playing Games, especially Video Games.