Search code examples
error-handlinggame-enginegodotautoloadgdscript

When i create a AutoLoad script i have an Invalid get Index 'runnig': (on base: 'null instance')


extends Control

onready var dialogue_box = $CanvasLayer/DialogueBox

var playing_intro : bool = false


func _ready():
    playing_intro = true
    if !dialogue_box.running:
        dialogue_box.start()
        

And i try to change AutoLoad name, but nothing happened. My solution is not to use the AutoLoad


Solution

  • Scripts do not come with a scenes attached.

    So when you Autoload your Script it won't come with the other Nodes you had in the scene where you designed it.

    In this case you are trying to access $CanvasLayer/DialogueBox which is not there because the Autoload is the Script not the scene.


    But scenes can have Scripts attached.

    So add your scene (the .tscn or .scn file) as Autoload.

    Then it should work.