Textureprogress bar value does not go zero

Godot Version

<stable4.2>

Question

<Im using two texture progress bar to make my boss health bar. one for front bar, and other one for background bar to smoothly decrease. Im using tween for background bar to do that and works perfectly except, when the health is zero, the background bar does not go zero. any idea why?

func take_damage(amount: int) -> void:
	print("take damage")
	print("DMG:", amount)
	health_barfront.value = health
	var value = health_barback.value
	value = health
	var tween = create_tween()
	tween.tween_property($"../BossHealthBar/BarFrame/TextureProgressBar2", "value", value, 0.5).set_trans(Tween.TRANS_SINE)
	health = max(0, health - amount)
	if health == 0:
		health_barfront.value = 0
		health_barback.value = 0
		change_state(States.DEATH)

move when you update the health bar value below where you calculate the health
it might be because you update the heath bar before you calculate the heath making your health 0 but your health bar never has a chance to update to 0

1 Like