Change players health based on scoreboard objectives
I have a custom map in which I have a scoreboard objective. Is there any way to change a player's health based on this scoreboard objective? The only thing I could find was putting a button on a player's head with the max health attribute but that has many disadvantages.
Best Answer
1st: /scoreboard objectives add [name] health [display name]
Add any name to name and display name
2nd: /scoreboard objectives setdisplay belowname [name]
Set the name you want to display at the scoreboard at name
(Your health will show up as 0 until you lose some...it's a bug)
Pictures about "Change players health based on scoreboard objectives"



How do you show health on the scoreboard?
Scoreboard CommandMinecraft Scoreboard Command Tutorial [1.18]
More answers regarding change players health based on scoreboard objectives
Answer 2
This is going to need a lot of command blocks.
Command 1: /scoreboard objectives add health health [Display Name of Objective]
Command 2: /scoreboard objectives setdisplay sidebar health
Command 3: /scoreboard objectives add hea health
Okay, this command is going to need to be in a loop.
/testfor @a[score_health_min:20,score_health:20]
(Put a compartor here)
/effect @a[score_health_min:20,score_health:20] minecraft:regeneration 2 255
Now, make another loop.
/testfor @a[score_health_min:18,score_health:18]
(Compartor)
/scoreboard players set @a[score_health_min:18,score_health:18] hea 18
Another loop:
/testfor @a[score_health_min:16,score_health:16]
(Compartor)
/scoreboard players set @a[score_health_min:16,score_health:16] hea 16
Continue this, counting down by 2 every time and adjusting accordingly.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Andrea Piacquadio, Karolina Grabowska, Ketut Subiyanto, Artem Podrez
