The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

I've tried following the Singletons Autoload step by step tutorial both for Godot 2.1.4 and Godot 3 and both have produced the same error which I've been unable to figure out.

When the button in scene_a is clicked the game crashes with the following error "Attempt to call function 'instance' in base 'null instance' on a null instance."

The errors point to _deferred_goto_scene function which looks like this.

func _deferred_goto_scene(path):
    var s = ResourceLoader.load(path)
    current_scene = s.instance()


More specifically, it seems something odd is happening in ResourceLoader.load(path). the path variable ( res://scene_b.tscn ) gets passed on correctly to the function but ResourceLoader.load(path) still seems to return a [Object:null]. The game therefor crashes on when trying to instance s.

Note that the project I am testing this on is the one downloadable on the mentioned page in the documentation.

Did I miss something or is there something missing from the documentation?

in Engine by (30 points)

1 Answer

+1 vote
Best answer


The problem are these strings in the latest docs:
"res://scene_a.tscn" and "res://scene_b.tscn"
The downloadable file contains .scn files.

Not sure how you run into this with the stable docs. There the strings are correct...

I tested it with Godot 2.1.4 and Godot 3 beta1 and it works for me.
Here are my project files:

The only problem I came across was this wrong picture in the stable docs:

Project Settings

In 2.1.4 the Path is on the left and the Node Name is on the right side of the window. But no change in behaviour at all.

by (1,036 points)
selected by

haha! yes. this is correct. I had both the stable and latest docs open as I was testing this with both Godot 3 and Godot 2. My guess is that I must have alt tabbed to the wrong one when checking the code and then never really noticed the extra t!

Thank you very much for the help. Works now. :)

No problem. Would you mind creating an issue in the docs repo because of the missing tscn-files in the provided zip file (only latest docs)?

You could link to this thread to make the problem more clear.

I will look into that, no problem.

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.