How To Await a Signal from A Different Script

Godot Version

4.4

Question

Script A emits a signal
Script B is awaiting it - is this possible? If so what syntax should I use?

Script A:

signal charLoaded

charLoaded.emit()

Script B:

var myScriptA : ScriptA # make reference

await myScriptA.charLoaded #? This doesnt work

Thanks I appreciate it

Looks correct, why doesn’t it work?

1 Like

WHEN is each thing done.

your node can be emitting the signal before the other script gets to await. nodes are executed in the order they appear in the tree.

a simple but limited solution is to call_deferred, but this can only be done once, as it makes the function run last.

the code you posted is insufficient to diagnose any problem.

Thanks - after further testing, I suspect it is working, but firing the signal before the await is ready. Thanks