Executing a testfor command not working

Executing a testfor command not working - Pensive Man Sitting Behind His Desk Using Laptop

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.



Pictures about "Executing a testfor command not working"

Executing a testfor command not working - Person Holding Brown Leather Book
Executing a testfor command not working - A Man in a Suit Reading a Document on his Work Desk
Executing a testfor command not working - A Secretary Handing a Pen to her Boss



What replaced the Testfor command?

The /testfor command became obsolete in Minecraft 1.13, and has been replaced by the /execute command*. It will do the same as typing /testfor @e {SelectedItem:{id:"<item>"}} and then putting a comparator to the command block with the command, and then running the command which you wanna run.

How do I use the Testfor player command?

How to Enter the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.


  • How do you use Testfor command in bedrock?

    You can test whether there is a certain block at a specific location in the game using the /testforblock command in Minecraft....TestForBlock Command in Minecraft Java Edition (PC/Mac)
  • x y z is the coordinate to test. ...
  • block is name of the block to test for. ( ...
  • dataValue is optional. ...
  • dataTag is optional.




  • Comparator Testfor Problem fix




    More answers regarding executing a testfor command not working

    Answer 2

    This is natural behavior if nothing was found. According to this wiki page, the testfor command fails if no entities match the selector. It appears that your command block is working properly.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Kampus Production, Pixabay, RODNAE Productions, RODNAE Productions