Here is the code I am working with. I have been able to figure out that var health is null but I cant figure out why since it should be set to max_health on ready (and yes the max health export is populated). Any and all help is appreciated, thanks!
signal health_changed
@export var max_health : int
var health
func _ready():
health = max_health
emit_signal('health_changed', health * 100 / max_health)
func take_damage(amount):
health -= amount
emit_signal('health_changed', health * 100 / max_health)
if health <= 0:
explode()
From a different script that should initiate the take_damage function
func _on_body_entered(body):
print("bullet hit")
explode()
if body.has_method('take_damage'):
body.take_damage(damage)