Script "" in BackgroundLoading docs is giving me errors, how to fix it?

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

When I start the class “” following the example steps in the documentation it gives me errors when I try to use the method queue.queue_resource().

The error is caused in the part:

func queue_resource(path, p_in_front = false):
if path in pending:
elif ResourceLoader.has_cached(path):
	var res = ResourceLoader.load(path)
	pending[path] = res
	var res = ResourceLoader.load_interactive(path)

#Exactly here: res.set_meta("path", path)

With the message:

Attempt to call function ‘set_meta’ in base ‘null instance’ on a null instance.

Could anyone help me with this situation? I assumed fully functional examples would come in the documentation. But since this does not work, I ask this question.

:bust_in_silhouette: Reply From: timothybrentwood

“Attempt to call function ‘set_meta’ in base ‘null instance’ on a null instance” means that the variable res is null at the time of calling the set_meta() function on it. Which means ResourceLoader.load_interactive(path) returned nullbecause either you sent it a bad path or a resource doesn’t exist at the path you sent it. Add:

func queue_resource(path, p_in_front = false):

Then run it again, when it crashes on you verify the last path does point to a resource.