# Godot

# Common questions

## Why would you use `onready var` versus regular `var`?
- `var` is assigned when the script instance is created, if this is a node then it might not be added to the tree yet, so you can't use `get_parent` and similar on it.
- `onready var` is a shortcut for assigning vars in `_ready()` and is assigned a value after a node and siblings enter the tree. Only useful for nodes.

[Reference](https://godotengine.org/qa/12000/is-there-any-reason-to-use-var-instead-of-onready-var)

# Troubleshooting

## A connected event is not receiving the emitted signal
Make sure the handler is accepting the same number of arguments. For example if the emitted signal adds a context argument, then the connected handler must also accept the context argument, otherwise it is never called.


```gdscript
extends Node2D

func handle_mytrigger():
    # never reached as we are not accepting the argument!
    print('nope')

func _ready():
    Events.connect("mytrigger", self, "handle_mytrigger")
    var myplayer = 'me'
    Events.emit_signal('mytrigger', myplayer)
```