How can i use Autoload without no error?!

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

In other scripts, i wanna use updated var values in “”. So i was setting autoload. But i got error in

How can i solve this problem?!

:bust_in_silhouette: Reply From: crossbito

Hi, maybe you could try adding “await” to your variable like this:

@onready var animationState = await $AnimationTree.get("parameters/playback");

Alternatively, you can set the variable in the _process function because maybe you are using your script in an object that doesn’t have an AnimationTree:

@onready var animationState=-1;

func _process(delta):
	if(find_child("AnimationTree") && animationState==-1):
		animationState = $AnimationTree.get("parameters/playback");

I hope it helps!

If not using autoload, is there other ways using var to other scripts?!

Finally, understood. I didnt think that is about all the other objects. So i wanna know other ways. For example, i wanna use from var in “” to “”,s var. And if A’s var is changed, B’s var also changed too. Not use autoload. How can i do this?! I was googling, but couldnt solve this. In “load” or “preload” coding way, i can load inital setting var but i cant load updated var values. Plz help me.

nagne | 2023-05-30 00:51