Help with signals

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

(sorry for bad english, using google translator)

I made a signal in my player’s scene script that tells the map that its life reached 0, so it can queue free the Player and call the game over scene.

Player script example:

signal is_dead

func _on_dano_body_entered(body):

   life -= 1

if life <= 0:

Map script:

onready var game_over = preload("res://GameOver.tscn")

func _on_Player_is_dead():
    var fim = game_over.instance()

On the first map it works perfectly, but on the second one apparently the signal is not being emitted, he’s lifes reach 0 but nothing happens (the second map uses the same script as the first).

Thanks for read.

Did you connect the signal again in the second map? Can you put a print statement before the emit_signal call and see if the function is called at all?

exuin | 2021-06-06 17:36

Thank you very much, I really hadn’t connected it on the second map.

It’s working now :D.

abcdob | 2021-06-07 00:04