How to affect players with a scoreboard score of 0

How to affect players with a scoreboard score of 0 - Aerial View of Soccer Field

I am creating a simple thing for a project I am creating. I want to remove the "night_vision" effect from players with a "holdingTorch" score of 0.

I would think it would be done like this but it's not working:
/execute @a[score_holdingTorch=0] ~ ~ ~ effect @p night_vision 0

It keeps saying
The entity UUID provided is in an invalid format



Best Answer

The entity UUID provided is in an invalid format

This error means that the target selector being used did not find any targets, specifically for the /execute command (as the error would otherwise have been "failed to execute"). Therefore there were not any players with a "holdingTorch" score of 0.

If you are not setting the player's score to 0 first, then they will not have a score at all to detect. You would need to force their score to be 0, such as setting it to 0 before setting it to 1:

/scoreboard players set @a holdingTorch 0
/scoreboard players set @a holdingTorch 1 {SelectedItem:{id:"minecraft:torch"}}

You should not be using @p as the nested selector when the executor is @a in order to target the executing player. The only selector that can target dead players is @a, so by causing dead players to remove night vision from @p, they will not remove it from themselves but instead remove it from the nearest-living player to their dead body.

The fix is to use the same selector, such as @e[type=Player] as the executor with @p as the nested selector, or @a as executor and @a[c=1] as nested selector.

/execute @e[type=Player,score_holdingTorch=0] ~ ~ ~ /effect @p minecraft:night_vision 0

Or:

/execute @a[score_holdingTorch=0] ~ ~ ~ /effect @a[c=1] minecraft:night_vision 0

If you're using 1.9+, you will want to use scoreboard "tags" instead of scores. These are more efficient to use and will not bloat scoreboard.dat as the tags are saved on the entities themselves:

/scoreboard players tag @a[tag=holdingTorch] remove holdingTorch
/scoreboard players tag @a add holdingTorch {SelectedItem:{id:"minecraft:torch"}}

/execute @a[tag=!holdingTorch] ~ ~ ~ /effect @a[c=1] minecraft:night_vision 0



Pictures about "How to affect players with a scoreboard score of 0"

How to affect players with a scoreboard score of 0 - Football Players
How to affect players with a scoreboard score of 0 - Gathering Football Players
How to affect players with a scoreboard score of 0 - Low Angle Photography of Basketball Dunk



How does the score system work in Minecraft?

Score increments automatically for a player when they die. Score increments automatically for a player when they kill another player. Score increments automatically for a player when they kill another player or a mob. Ranges from 0 to 20 on a normal player; represents the amount of half-hearts the player has.

How do you add points to a scoreboard in Minecraft?

Scoreboard Command
  • To add an objective: /scoreboard objectives add <objective> <criteria> [displayName]
  • To remove an objective: /scoreboard objectives remove <objective>
  • To list all objectives: /scoreboard objectives list.
  • To set how the objectives are displayed: /scoreboard objectives setdisplay <slot> [objective]




  • Minecraft Scoreboard Command Tutorial [1.18]




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

    Images: Mike, Joe Calomeni, Pixabay, cottonbro