This is my first attempt at using scoreboards for accomplishing tasks so I'm still learning. I'm trying to make a golden helmet behave as night vision goggles by giving the player the night vision effect.
Here's what I've done so far:
Create a dummy objective named "nightVision".
Place this command in a clock:
scoreboard players set @a nightVision 0
Then this command:
scoreboard players set @a nightVision 1 {Inventory:[{Slot:103b,tag:{display:{Name:"Nightvision Goggles",Lore:[Equip to see in the dark!]}}}]}
And finally this command:
effect @a[score_nightVision_min:1] 16 30 0 true
I've tested it by wearing the helmet mentioned above on my head and doing a scoreboard test command. It works if I combine steps 3 and 4 into one testfor command and run a comparator out of it:
testfor [player] {Inventory:[{Slot:103b,tag:{display:{Name:"Nightvision Goggles",Lore:[Equip to see in the dark!]}}}]}
But that seems like the very thing scoreboards could be used to avoid.
I've tried taking out the first command because I thought maybe the scores were being reset too fast but it still doesn't work. I've come to the conclusion that my error is either in step 3 or step 4 but I'm not seeing it.
score_nightVision_min=1