Minecraft – Executing a testfor command not working

minecraft-commandsminecraft-java-edition

I'm working on a capture the flag minicame in Minecraft 1.8.1. One of the features is automatically picking up flags when a valid player is in range. To accomplish this, I placed an armor stand inside each flag.

The goal is to get that armor stand to test for valid players (i.e. not on the same team, doesn't already have a flag, etc.) and set the block that was the banner to air. Each flag has a certain rotation value that is used to tell what team it represents – in this case, a rotation (ry and rym in the command) of 0 means the blue team. So, this command should tell all armor stands with a rotation of 0 to check for players not on the blue team who don't already have a banner.

Here's the command that isn't working:
execute @e[type=ArmorStand,ry=0,rym=0] ~ ~ ~ testfor @p[r=2,score_hasBanner=0,team=!blue]

And here's the error: Failed to execute '/testfor @p[r=2,score_hasBanner=0,team=!blue]' as Heads Up ("Heads Up" is the custom name of the armor stand, don't worry about why)

This error tells me that the execute command must be working fine, meaning it's a problem with the testfor command. However, using the testfor part on its own works perfectly.

Any ideas? Thanks in advance.

Best Answer

The command itself is completely fine, and works for me:

enter image description here

Make sure:

  • You are within range of the ArmorStand that is actually executing the command. If you have multiple ArmorStands with 0 rotation (likely, as they spawn like that by default) the output will only show the result of the ArmorStand that happens to execute last, which may not be in range.
  • You actually have a hasBanner score of 0. The default score for an objective is unassigned, not 0, so make sure it's being set to 0 somewhere.
  • You are not on blue team.