I am trying to make a command block that when powered, it will looks for a specific player in a 5 block radius of the command block. I tried

/testfor @p[r=5][name=<name of player>]

but it doesn't work.


You can't use two [] next to each other.

/testfor @p[r=5,name=<PlayerName>]

Use a comma to separate different values. Don't add another [] next to it.

  • 1
    This does not work either. Did you find a solution? – Lawrence Thurman Dec 28 '14 at 19:50
  • Did not realize name is case Sensitive – Lawrence Thurman Dec 28 '14 at 20:04
  • can we test for name!=MyName ? – user97009 Dec 29 '14 at 21:44
  • @Sivmatt we can, but Minecraft uses name=!MyName for that, i.e. "name equals (not MyName)". Same for other fields such as type – MrLemon Feb 25 '15 at 12:26
  • Will this work if there is one player closer to the command block? It seems like using @a instead of @p is better. – Anders Lindén Jan 19 '17 at 18:49

protected by Community Dec 29 '14 at 22:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.