What is the command to give a player a diamond helmet if they have a specific scoreboard score? [duplicate]

I am making a map and I want to be able to give points to players, which I have down (using the scoreboard command). But I want to be able to see if a player has a specific score and reward them with a diamond helmet.


Also, I want to replace the item on their head with the diamond cap, not just use /give to give it to them. If you can give me the command or set of commands that would be great! I'm using 1.9.2.


Solution 1:

/give @a[score_name_min=1] minecraft:diamond_helmet

is the command to give everyone with a minimum score of 1 in 'name' a diamond helmet. Just replace the objective 'name' with your own name.

/give @a[score_name_min=1,score_name=1] minecraft:diamond_helmet

is the command to give everyone with an exact score of 1 in 'name' a diamond helmet. Just replace the objective 'name' with your own name.

As for replacing inventory items; I do know a way for 1.9.2, but for 1.8:

/give @a[score_name_min=1] {Inventory:[{Slot:103b,id:"minecraft:diamond_helmet"}]}

would give it in slot 103b (I believe this is the helmet slot, but I am not sure.)