Connect signal using code

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

Hello! I’m following the tutorial at Using signals — Godot Engine (stable) documentation in English
and it spits an error at me when i try to func _ready(): ....var timer = get_node('Timer') ....timer.timeout.connect(toggle_visibility), where toggle_visibility is a declared function.
The error remains even if I copy-paste the code into the editor.
How do I do this?

:bust_in_silhouette: Reply From: spaceyjase

You posted 4.0 code and linked to the G4 documentation, but are using an LTS? You likely want the version of the documentation that matches:

func _ready():
    var timer = get_node("Timer")
    timer.connect("timeout", self, "_on_Timer_timeout")

You can change the documentation version down the bottom left of the screen where it says ‘Read the Docs’