What did i do wrong?

Godot Version



Hi i am making health system in my game but i dont know why when the hp variable change in global script it didnt change in textureprogress even when i have the signal. What am i making wrong here? It updates when changing scenes but not when i got hit…
Here is global script:

extends Node2D

var mapposition = Vector2(24, 19)
var mapposition2 = Vector2(24, 19)
var _hp = 100
export(int) var speed = 80   
var coin = 0
var strength = 10
var key = 0
var pocetzabiti = 0
var level = 1
var dialog1 = 1
var skeleton_attack = 5
var skeleton_damage = 5

signal hp_changed(new_hp)

func set_hp(value):
	if _hp != value:
		_hp = value
		emit_signal("hp_changed", _hp)

func get_hp():
	return _hp

onready var max_hp = 100

func set_max_hp(value):
	max_hp = value

func get_max_hp():
	return max_hp

func increase_hp(amount):
	_hp = min(_hp + amount, max_hp)
	emit_signal("hp_changed", _hp)

func decrease_hp(amount):
	_hp = max(_hp - amount, 0)
	emit_signal("hp_changed", _hp)

here is textureprogress script:

extends TextureProgress

func _ready():
	Global.connect("hp_changed", self, "_on_hp_changed")
	max_value = Global.get_max_hp()

func _on_hp_changed(new_hp):

My HP change in skeleton script so here is part of it with hp function:

func _on_Area2D2_body_entered(body):

isattack = true
	hpminus = 1
	yield(get_tree().create_timer(1), "timeout")
	if isattack == true:
		$AnimatedSprite.play("attack down")
		$attackzone/CollisionShape2D.disabled = false
		Global._hp = Global._hp - Global.skeleton_attack
		emit_signal("health_changed", Global._hp)

emit_signal("health_changed", Global._hp)

That signal isn’t defined anywhere.
And if you try to change it to
emit_signal("hp_changed", Global._hp)
it also won’t work (I think) because that signal isn’t defined in the skeleton script.
(Its easy enough to try it though in case I am wrong)
You are going to have to define a signal in the skeleton script and connect a global function to it.
From there you can pass along the signal to textureprogress.

PS: this onready is not necessary.

onready var max_hp = 100

A variable that does not contain a node or resource is ready immediately.

There is a discrepancy between the signal definition and usage. The signal name should be the same in both cases.