What can i do to make my variable accesable for others scripts?

Godot Version

v4.1.3.stable.mono.official [f06b6836a]

Hi, I am quite new in Godot and I’m looking for methods of exporting my variables.
Currently I’m working at quiz. The problem is I have separate scenes for each question and I don’t know how to add value to main script int (main script is attached to non-question scene) If I answer correctly.

Thank you in advance

Create an autoload script to keep all variables that should be accessible from any other scripts.

1 Like

Sorry i didnt mention that this is part of bigger project. And i dont have acces to it. My collegue will implement my part to this “bigger project”. So i suppose i cant use autoload. Let me know If I am wrong.

use emit signal.
connect the signal when you instantiate + add_child the question scene
then when you need to add score to main scene, just emit the signal

is this main script just a script that’s not attached to any node or there’s? if so then you can add the node attached to a group and just get the main script node by group name
if your main script node and question is already existed since the beginning of time (added via editor), then you can just reference the node by nodepath

there are many ways to do it

Thanks it works but i have feeling that this is not optimal becasuse after clicking answer i have to hide one question and show another. I would appreciate better solution or just saying this is ok.