How do I code a TextureProgress as a health bar?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sousr

I have been trying to code the TextureProgress into a health bar, but it is not working. The value will not decrease when my character comes into contact with the enemy. $HealthBar is the textureprogress. I have coded the decrease in value in the enemy script as:

func _on_Area2D_body_entered(body): #connected signal
	if body.get_name() == "Character":
		body.respawn()
        $HealthBar.value(-15) 

value keeps returning as a null instance

and the health bar code is:

onready var health_bar = $HealthBar

func _on_health_updated(health, amount):
	health_bar.value = health

func _on_max_health_updated(max_health):
	health_bar.max_value = max_health
:bust_in_silhouette: Reply From: mdubaisi

in the signal:
$HealthBar.value -= 15

because the value is property not a function so it doesn’t use brackets.

Thank you for your help! I will make changes accordingly.

sousr | 2020-08-30 21:17