Changing color of health bar only works when health decreases, but not when it goes back up

Godot Version

4.2

Question

I have this function that changes the color of the player’s health indicator as it decreases. When health reaches 75% it turns yellow, 50% it turns orange, and so on. It works when health is reduced, but it doesn’t go back to the previous colors as health increases. Here is the function:

image_2024-03-16_082429789

My suspicion is that it’s because I’m using elif and when it reaches the final elif statement, instead of going back around, it just stops checking because it reached the end of the function? Is that the case? And, if so, how else could I implement it in a way that it behaves how I need it to (colors change when health decreases, as well as increases)?

If Global.health and the *_health variables are floats you should be using @GlobalScope.is_equal_approx() for comparison as floats aren’t exact

For some reason it’s working now and I’m. Not sure why, as I didn’t change anything, at least that I can recall. But I’ll still make this change as I forgot that floats aren’t exact.