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.

1 Answer 1


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? Commented Dec 28, 2014 at 19:50
  • Did not realize name is case Sensitive Commented Dec 28, 2014 at 20:04
  • can we test for name!=MyName ?
    – user97009
    Commented Dec 29, 2014 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
    Commented Feb 25, 2015 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. Commented Jan 19, 2017 at 18:49

You must log in to answer this question.

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