Can't access var from another Scene

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

I’ve been trying for a while now to make this script work, the code that i’ve wrote for it currently grabs a new instance of the “” script, but i want to make so that the Script grabs the actual “” script, because any updates that happen to the original script don’t appear in the new instance

What could i do in the code to make that happen?

extends Label

var GridSizeUI_Script = load("res://Scripts/").new()

func _process(delta):
	text = str(GridSizeUI_Script.NT)
:bust_in_silhouette: Reply From: Inces

I can’t understand that. It sounds like You just want to print actual NT variable of some gridzise instance. Instead of creating new script just use reference to this one original gridsize instance, that keeps actual values of NT. It is somewhere in your scene, isn’t it ?

Do you know of any way through which i can do that?

The script i’m trying to access and this script i’ve shown the code to are in two different scenes

Megatt4 | 2021-11-06 16:48

Ok, but how do You update script in another scene ? Is it some kind of tool scene, which You run and it saves variables to this scipt for use of whole project ? Or is it more like previous level scene and You want to keep data to next level ? Or is it a scene that You only tweak in editor and You want it to be kept for whole project ? Please tell more about what is this script for

Inces | 2021-11-06 19:13

:bust_in_silhouette: Reply From: timothybrentwood

You probably want to make Grid_Size_UI a Resource instead of a script. Doing so will make it so there is only ever one Grid_Size_UI object in memory.

Everything you would want to know about resources from Godot:

An easy to follow tutorial about how to use resources: