I'm searching how to tag two Players using one /testfor command. I'm actually using this command which works for one person :

/testfor @a[name=!<pseudo>,r=15]

But it doesn't work for two Players. Is it possible?

  • 1
    So, because I want command blockers in general to better command blockers, I have to ask: why are you using testfor? Are you just using it as an example in this question, since it's an easy way of presenting your target selector, or some other reason? I only ask because testfor is only useful in a limited number of cases when compared to other options. I urge you to consider the problem more deeply, and think about which command is truly right for the job.
    – MBraedley
    Apr 6 '16 at 20:49
  • Hmmm... I'm using testfor because i'm creating a secured bank and I needed only two person which can enter in (the bank owner, and me the admin of the server).
    – Fyrens
    Apr 8 '16 at 11:42
  • Okay, in that case testfor probably isn't the right tool for the job. I would just use the scoreboard (probably tags) and a selector to do this to teleport anyone that isn't tagged out of the bank.
    – MBraedley
    Apr 9 '16 at 2:27

First, create a dummy scoreboard objective:

/scoreboard objectives add selectMe dummy  

Then, add 2 players to the "selectMe":

/scoreboard players set @e[name=Name1] selectMe 1  
/scoreboard players set @e[name=Name2] selectMe 1  

Now you can enter your command:

/testfor @a[score_selectMe_min=1,r=15]  

or you can use this for an opposite effect:

/testfor @a[score_selectMe=0,r=15]  

Help gotten from here

  • 1
    There is no score_name_max parameter. The parameter you want is simply score_name. And that still won't work if players do not have a score prior (as they are not automatically tracked with a score of 0), meaning you'd need to set scores to 0 first.
    – Skylinerw
    Apr 6 '16 at 20:10
  • 1
    Personally, I'd use scoreboard tags instead of actual scores. They're designed for exactly this type of thing.
    – MBraedley
    Apr 6 '16 at 20:52
  • For future reference: Code formatting works better for Minecraft commands than block quotes.
    – MrLemon
    Apr 7 '16 at 11:57

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