Minecraft Java Edition – How to Calculate Player Health Percentage

minecraft-commandsminecraft-java-edition

I have created the following objectives:

  • health – health
  • health1 – dummy (used for health*100)
  • healthPerc – dumny (used for health1/20)

The only problem I'm having is that when I do: /scoreboard players operation @p health1 *= 100 health, it says Set [health1] for Username to 0 (having 20/20 hearts)

How do I do this?

Best Answer

It's a but unfortunate, but Minecraft actually sees "100" as a valid username. Where you wrote it, you need a name, which can also be a dummy player. You need to assign that dummy player or entity the value 100 in some scoreboard and then you can use that for operations.