If you change the health value twice quickly it will bug out a bit, but otherwise it works fine. Just move the Hp slider. It's only there for testing purposes and would be hidden if this were to actually be used. While you likely won't want to use this, if you do please just credit me.
Also check this project out, I didn't look at its code when making this but it is what inspired me to make it. https://scratch.mit.edu/projects/1378509308/