3

I'm making a dungeon style game, and I want the mobs to have their health above their head, and update when they heal or get hurt. Is there anyway to do this with just command blocks/commands. Because all of the answers that I've found are either mods, or don't work.

2
  • I found something similar that has been asked before. This might answer your question: gaming.stackexchange.com/a/306479/189958
    – hair444y
    Commented Sep 14, 2021 at 12:52
  • you could try doing scoreboard commands, one for each mob (but that means you'll have to have a fixed amount of mobs) and put them as "show under name" instead of the sidebar
    – Cyanite17
    Commented Sep 17, 2021 at 19:04

1 Answer 1

1

Try this, it should work.

scoreboard objectives add Hp health

scoreboard objectives setdisplay belowName Hp

execute as @e[type=!player] at @s run scoreboard players add @s 0

scoreboard players add @a Health 0

'hp' is the scoreboard name

'health' links health of the entity to the scoreboard

'scoreboard objectives setdisplay belowName Hp' makes the hp visible above the name or head

'execute as @e[type=!player] at @s run scoreboard players add @s 0' adds every entity but players to the scoreboard. meaning their health starts being tracked by the scoreboard

'scoreboard players add @a Health 0' adds players to the scoreboard

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .