How to add to a variable anything thats added to a different one?

I use a health bar as a level indicator. -
I want the bar to reset when its full and refill again (showing progress to next level).
For that i created a variable which supposed to track the money being *added to the total money, and once the bar is full ill reset it.
How can i do that? Or is there a better way?
(its a clicker game, the bar max level will be increased each new level)