Minecraft: /testfor problem

minecraft-commandsminecraft-java-edition

So I was doing a command creation of an Explosive Bow. I was trying to use /testfor to test arrows near me in order to detect them if they are from a different type of bow.

Arrows with score of 1 on score telar is a teleportation arrow
Arrows with score of 1 on score lhar is a lightning arrow

So this is my command:

execute @a[score_bow1_min=1,score_bow1a_min=1] ~ ~ ~ testfor @e[r=3,type=Arrow,score_telar_min=0,score_telar=0,score_lhar_min=0,score_lhar=0]

So yeah, that's why I'm here asking, it didn't work well.

It returned this error:

[Current time] Failed to execute testfor @e[r=3,type=Arrow,score_telar_min=0,score_telar=0,score_lhar_min=0,score_lhar=0] as myname

I removed the /execute command and the code returned this error:

[Current Time] testfor @e[r=3,type=Arrow,score_telar_min=0,score_telar=0,score_lhar_min=0,score_lhar=0]
found nothing

Near me was a plain arrow with no scores at all, and I swear I'm inside the specified radius or what is specified in the r tag.

Please help.

Best Answer

Notice the difference between "a score of 0" and "no scores at all". If an entity doesn't have any scores at all, then it means that the entity is not present on any scoreboard. If the entity has a score of 0, then it means that the entity is present on the scoreboard with score 0.

You are testing for arrows that have a score of 0 on telar. The Arrow that you expected to show up, doesn't have a score of 0, but simply isn't present on the scoreboard. For this reason, that Arrow is not detected with the testfor command. If you still want to test for arrows that don't have a score assigned yet, you should add 0 to all entities on each scoreboard every tick with the following command:

/scoreboard players add @e[type=arrow] telar 0

This command adds 0 to the score of all Arrows on the telar objective. If an Arrow isn't present on the scoreboard yet, then it is added to the scoreboard with value 0.