Test whether Minecraft hearts are below 4?

Me
3

I need a command whether the hearts are below 4 (i.e. 2 hearts).

That can be done with execute but I'm just too stupid.

Br

I'm not the best there, but I think I can help you with that.

You can use a scoreboard for that you enter / scoreboard objectives add heart health and then with a Testfor Command maybe it tells you something whether it works with execute I unfortunately don't know I'm not the news version player

Hope could help you a little further with that

M.F.G Don Goldi

Sc

That is possible with a scoreboard

First you create a scoreboard that checks how many lives the other players and you have:

/ scoreboard objectives add life health

(to make the scoreboard visible, use the following command / scoreboard objectives setdisplay sidebar life)

If you or your teammates get harmed, this will be shown in the scoreboard. The following command is used for the adjustment:

/ execute if score @p life matches .4 run say too little life

The command compares whether the player @p (i.e. You) is at 4 or less (therefore the 2 points) lives.

Me

Thanks have already informed me and yes it works, just thought that matches the same as = is somehow stupid that it is not one: /