How can i use a signal correctly?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By robert:_elizalde
:warning: Old Version Published before Godot 3 was released.

I want that a label show “Greate” when the score comes to 3 and I have a variable where the scored is saved and i have this:

> if game.score_current == 3: 			
>     emit_signal("final_boss_enter",self) 		
      pass

And on an Built-In Script of the label I have this:

> func _ready(): 
    hide() 	
> 	connect("final_boss_enter",self,"_show_perfect_label") 	
    pass 
  func _show_perfect_label(simple_node): 	
    show() 	
    pass

But it doesn’t work. I dont now if im using singnals correctly Help!

Your debugger and/or console are probably giving you errors giving you some description of what’s “not working”.

The problem you have here is you are trying to connect the signal from the label, when it should be called from the object that’s emitting the signal.
Rather than connect(..), you want get_node("path/to/player").connect(..)

YeOldeDM | 2017-04-21 08:16

As YeOldeDM said :

The script where your “emit_signal” is writted is, I guess, probably associated to a node (For example, named “Player”).

In the case of a connection, you must have this pattern :

[node_emitting_signal].connect( [signal_emitted] , [node_receiving_signal] , [function_to_call_in_node_receiving_signal] )

The godot’s doc can be found here :
Object — Godot Engine (stable) documentation in English

mbenoni | 2017-04-21 09:38

Thanks, it was hard to understand the documentation at first, but i folllowed your instruccions and it worked perfectly. Thank for the support

robert:_elizalde | 2017-04-24 07:05