How to use singleton in godot?

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

I am new to godot i moved from unity to godot and now I wan my game to change between different scene and also during change not to loose some of the data needed how to do it ? i have about singlton in godot manual but I am not able to understand it and It will be really helpful for me if you can please .

:bust_in_silhouette: Reply From: klaas

just write a script. Go to project settings autoload. create new autoload provide the script file and choose a name. Set as singleton.

Now you can access the script from everywhere under the given name.