Are you sure you put the statement in the right method? I just tested it by copying your script into a new project and adding zero/max checks in the update function and it seems to be working fine. void Update() { HandleHealthbar(); if (Input.GetKeyDown(KeyCode.Space)) { Health -= 10; } if (Health <= 0) { Health = 0; } if…
I think you might be looking for the clamp function, it lets you specifiy a min/max value, and if your variable is outside of that range when you use the function, it gets cut off to the min or max value. Saves you some lines of code, too :) http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html