How do I create global variables / scripts?

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

I want to create a global script in which I can establish variables, which can be used in every other script.

:bust_in_silhouette: Reply From: kidscancode

This is explained in the docs here:

Would it make more sense to link to the “stable” version? Not sure what users do here.
Singletons (Autoload) — Godot Engine (stable) documentation in English

Gatada | 2022-09-14 22:12

:bust_in_silhouette: Reply From: Gatada

Currently the steps are:

  1. Via menu option Project go to Project Settings > AutoLoad tab.
  2. Add your script.
  3. Give the script a self-documenting name, like: GlobalSettings.
  4. Access it via $/root/GlobalSettings.

But as suggested by @kidscancode, read the docs: