Variable value does not change


Maybe the problem is that when the button is pressed, new instances of the class are created, like here?
image
image
image
They are created when I click the button, then written to a variable (The idea is that if this variable is already valid, then do not create new instances). But as soon as I close this widget, then reopen it, click on the button, a new instance is created.

How do you close and open it?

I close widget using Remove From Parent

And how do you open it? Can we see the script?

which widget script?

Yes. How do you create / show and remove the widget. The widget with the variable.


remove using this script

And open / create?

That’s your problem. You create a brand new widget every time… It’s an instance, it has its own data.

Okay I realize I’m dumb, could you tell me how to save this instance please

You only create it once and reference it. It can then remove itself. When you click again, you use the existing reference to bring back the existing instance. It will retain the data.

  • you can automate reference creation like so:

  • and you can get the validated get node like so:


The above will work providing you do not do the same with this widget…

We see an ominous looking macro that may remove all widgets here, too!

I’ve been around for 10 years, I’ve seen people try:

And then try to do something in the widget. Every single one of them, all 120 of them created every second is unique and has its own data.


The good news is, we now know what is up!

Thank you so much for helping. I’m just really stupid

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.