How can I use command blocks to detect a specific player within a certain radius of the command?

I can detect a specific player, or a player within a certain radius, but not both.

  • 1
    Hi Ethan, what's the command(s) you've got so far? If you show us your work, we'll be able to help figure out what's going wrong :)
    – Robotnik
    Commented Jul 20, 2015 at 4:05

1 Answer 1


You can specify multiple arguments by separating them with commas. Enter the following command into a command block:

/testfor @a[name=<name>,r=<radius>], where <name> is a player's username and <radius> is the circular distance around the block.

You could put this command block on an infinite redstone loop to make it run over and over, all the time.

  • 1
    And to just detect any player in the radius leave out the name and just have the radius. Example : /testfor @a[r=<radius>] and he explained this well enough for you to get the rhythm of it.
    – Eisler 485
    Commented Jul 21, 2015 at 7:37
  • 1
    and to limit the number of players to detect use @p[c=<countMax>]
    – ydobonebi
    Commented Jul 28, 2015 at 5:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .