0

This is my command, it should only activate if all players have avance score on 0:

/execute if entity @a[scores={avance=0}]

I thought that with @a it would only be true if ALL players have that condition, but the command block output says "Test Passed, count 1" and that screws up the whole circuit as it depends on the command output being "Test Passed" only when all players have the same score on 0 to work.

2 Answers 2

1

There are multiple solutions, the easiest is to check if no player does not fulfill the condition:

/execute unless entity @a[scores={avance=1..}] unless entity @a[scores={avance=..-1}]

You can also add limit=1 to both of these selectors to improve performance. Thanks to vdvman1 for this tip.

6
  • it does not work, it says there is an error at "avance <--[HERE]" , expected "=", as soon as i type "!" the code turns red
    – D3T0NA
    Commented Nov 1, 2019 at 14:42
  • Oh sorry, I was used to Java (and pretty much every other programming language), where it's "!=". In Minecraft it's "=!" (for whatever reason). I corrected the command. Commented Nov 1, 2019 at 15:11
  • i do not know why but it turns red with both "!=" and "=!"
    – D3T0NA
    Commented Nov 1, 2019 at 16:52
  • you told me there are multiple solutions, do you know what else i can try?
    – D3T0NA
    Commented Nov 1, 2019 at 16:52
  • I'll try it in the game now, I wasn't at a computer so far. Another solution would be to tag all matching players and see if someone without the tag is left. Commented Nov 1, 2019 at 20:37
0
scoreboard objectives add test dummy "Test"
execute as @a run scoreboard players add $c test 1
execute as @a if score @s avance matches 0 run scoreboard players add $m test 1

First, count players. And then, count players that avance score is 0

execute if score $m test = $c test run say Same!

Finally, if players count is same as players that avance is 0, say Same!

1
  • 1
    The quote marks " around objective names are unnecessary.
    – One 2 Many
    Commented Feb 7, 2021 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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