1

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.

  • Do you want to change the maximal life the player can gain or just set its number of hearts (would regenerate normally)? – timakro Jan 3 '16 at 18:15
  • Gameryle natural regeneration false. – user124289 Jan 3 '16 at 19:46
  • There is no easy way to do this, since health is a read-only attribute. – MBraedley Jan 6 '16 at 2:38
-1

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)

  • Your solution does the opposite of what I asked for. I have an objective with a number in it and I want to set a players health to that number – user124289 Dec 31 '15 at 2:23
  • I have a dummy objective, and I want to change the player life based on that. – user124289 Dec 31 '15 at 2:27
-1

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.

  • 1
    There are a number of problems with this. The "health" objective-type cannot be modified (as you're doing with the "hea" objective). Parameters separate keys and values with equals signs, not colons. What is the /effect command doing; the player is already at full health, so why is it there? Setting a score does not actually modify the player's health. Why in increments of 2 rather than 1? – Skylinerw May 7 '16 at 11:35

Your Answer

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