I have been trying to get the health bar to drop when an enemy touches the player but i cant get it to work for the life of me

This is the script i have on my Player that has to do with taking damage (the rest is movement and shooting):

func damage():
	var health = get_node("HealthBar").get("health")
	var UpdatedHealth = health - 30

This is the health bar code:

extends ProgressBar

onready var health_bar = $HealthBar

export (float) var max_health = 100

onready var health = max_health setget _set_health

func damage():
		var UpdatedHealth = get_node("Player").get("UpdatedHealth")
		_set_health(UpdatedHealth)
		health_bar.value = health

func kill():
	get_tree().reload_current_scene()

func _set_health(value):
	var prev_health = health
	health = clamp(value, 0, max_health)
	if health != prev_health:
		if health == 0:
			kill()

And this is the code for the enemy touching the player:

if raycast.is_colliding():
		var a = raycast.get_collider()
		if a.has_method("damage"):
			a.damage()

My first thought was to call the fuction for dmg from the health bar when the raycast hits the player but i dont know how since the way i use the raycast it detects the player only so i am at a loss if anyone can provide any sollutions i would love it thanks

var UpdatedHealth = get_node("Player").get("UpdatedHealth")

I suspect that line causes an error, because in the Player script, the property UpdatedHealth is declared inside the function damage, so it's not visible outside that function.

a year later