My signal is not being recieved

Godot Version

Godot 4.3

Question

I am trying to create a signal that connects from the player to the game node so that after the player’s health is depleted the game changes to the game over screen. But for some reason even though I connected the signal the code isn’t working. This is my code:

game node (reciever):

extends Control

@onready var player = get_node(“CharacterBody2D”)
@onready var health = get_node(“/root/gameplay/CanvasLayer”)

var points = 100
var rock = load(“res://rock.tscn”)
var _posx = 1000
var _posy = [334,507,156]
var paused = false

func ready():
SignalBus.health_depleted.connect(_on_health_depleted)

var x = _posx.pick_random()
var y = _posy.pick_random()
inst(Vector2(x,y)) #Replace with function body.

func inst(pos):
var instance = rock.instantiate()
instance.position = pos
add_child(instance)

func _physics_process(delta: float):

pass

func _on_health_depleted() → void:
print(“gameover”)
paused = true
get_tree().change_scene_to_file(“res://Gameover.tscn”)

func _on_timer_timeout() → void:
if paused == false:
var x = _posx + player.global_position.x
var y = _posy.pick_random()
inst(Vector2(x,y))
#Replace with function body.
# Replace with function body.
else:
print(“game_paused”)

Player (emitter):

extends CharacterBody2D

signal take_damage
var paused = false
var health_level = 3

@onready var health = get_node(“/root/gameplay/CanvasLayer”)

var collision = move_and_collide(velocity)

func _ready() → void:
pass

func _physics_process(delta):

if health_level <= 0:
	paused = true
	SignalBus.health_depleted.emit()
if paused == false:
	var direction = Input.get_vector("left","right","up","down")

	
	if Input.is_action_pressed("down"):
		velocity.y =- -150
		

		
	if Input.is_action_pressed("up"):
		velocity.y =- 150
		
		
	if paused == false:
		velocity.x =+ 500
		move_and_slide()

func _on_area_2d_body_entered(body: Node2D) → void:
pass

func _on_area_2d_area_entered(area: Area2D) → void:

emit_signal("take_damage")
health_level -= 1

Is your ready function declared correctly? it should be func _ready():

Make sure to paste code with proper formatting.

Tysm I changed the ready() to _ready() and it worked. next time I will try to format the code better.