0 votes

Hello everyone.
I have a problem with all the variables I have in an autoload script. In fact, the variables are initialized like this:

var point

in the script of the autoload. Playing, these variables are changed from other scenes with normal assigns like this:

Globals.point=2 #Globals is the autoload's name

When I try to print the value of the variable, in this case, I expect to see a 2. Instead when I try to print it in a _process function, it shows me something like that:

Null
2
Null
2
(...)

It seems to print me each time the initialization value of the variable and the new value.
If I try to add to the code something like this:

Globals.point=Globals.point+1

It prints me:

Null
3
Null
3
(...)

How can I solve that?

asked Jun 4 in Engine by Parrot (12 points)

If you mark the code and press the curly brackets icon, the code will be shown as code, not as normal text. It's better to read then.

Is there maybe a scene you are playing in which any node has the Globals.gd script attached?

That was the probem! Thank you for the hint. I had already look for that but I missed out a General node attached to another node.

Flag is used to label comments as spam or inappropriate

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.