Signal inside of if statement not emitting

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

I’m very new to Godot I have an enemy that when its gets destroyed it changes a global variable by 1, the code that it is connected to checks the value and if it isn’t 0 it changes it by -1 and in that if loop thing it emits a signal to my progress bar to change its value.

 extends Control

var death = 0
signal add_time

func _process(delta: float) -> void:
	if death != 0:
		emit_signal("add_time")
		death -= 1
		if death <= 0:
			death = 0

And the progress bars code

extends ProgressBar


func _process(delta: float) -> void:
	value -= 1 * delta
	if value <= 0:
		value = 0

func add_the_time():
	print("added time")
	value += 3
	if value >= 10 :
		value = 10


func _on_control_add_time() -> void:
	add_the_time()
:bust_in_silhouette: Reply From: Tovns

I just needed a break instead of resetting the global variable then sending a signal I just changed it to the progress bar and changed it but I still had the keep the control node because if I don’t it adds a percentage in the middle of every scene

Progress bar code:

extends ProgressBar


func _process(delta: float) -> void:
	if deaths.death != 0:
		add_the_time()
		deaths.death -= 1
	value -= 1 * delta
	if value <= 0:
		value = 0

func add_the_time():
	value += 3
	if value >= 10 :
		value = 10

Global variable Code :

extends Control

var death = 0