I need to run a command for @a that doesn't have a score of 1. Is there a way to do that? (0 wont work because the default is no score, not 0). I would list my command but I'm not sure of the format. I want it to set all players without a score of 1 to /gamemode Survival. Any suggestions?


You cannot directly target somebody that has no score instantiated.

If you absolutely need to avoid any score except 1 (i.e. a score of 0 or lower, 2 or higher, or no score at all), you can label players that have a score of 1 and then target players without that label:

/scoreboard players tag @a[score_OBJ_min=1,score_OBJ=1,tag=!one] add one
/gamemode survival @a[tag=!one]
/scoreboard players set @a[tag=!one] OBJ 1

The benefit here is that no commands here are constantly running, as players that did match will no longer do so.

An alternative is to add 0 to their score in order to instantiate it with a default of 0, which will not change their score if they're already tracked:

/scoreboard players add @a OBJ 0
/gamemode survival @a[score_OBJ=0]
/scoreboard players set @a[score_OBJ=0] OBJ 1

The first /scoreboard command is always running, which may not be desirable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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