At the top of a script, I'm exposing a packed scene in the inspector, like so:

export (PackedScene) var my_instance

Then, as per normal, I am populating the variable's inspector field with a valid TSCN file.

But then, in my _ready() function, when I try to access the my_instance variable, I get an error indicating that it is Null value.

I'm using this same script pattern in other scripts on other nodes without issue where it works just fine. It's a very common pattern, as you know.

So, why, oh , why, does this one occurrence not want to work?

Anyone see this before?

Well, nevermind. The problem inexplicably fixed itself. I didn't change any code - just loaded a few different projects and then came back to the offending one and POOF, it suddenly worked as expected.

Might just be a glitch but if it does it again, I'll file a bug report.

a month later

Seeing the same behavior here, but loading other projects and going back to the offending one doesn't fix anything. This same exact concept worked fine when I ran through the "Creeps" tutorial where it's used to instantiate a specific Mob. When I try in a new project, I keep getting the exported PackedScene set to null even though the inspector clearly shows a scene loaded.

I've cleared and reloaded the property in the inspector multiple times to no avail. However, I just tried setting the property to a "New PackedScene" and now seeing a non-null value. Back in the inspector, I reselected/reloaded the scene I really want, and now it's working.

When I originally set the value, I drag/dropped the scene from the file explorer panel into the inspector. Thought maybe that had something to do with it...but now that's it's working, it continues to work regardless whether I drag/drop, or use the inspector dropdown to load the desired scene.

Seems "wonky" but is working now.

I have not tested this or anything, but from your descriptions it sounds like it could be a dependency graph/update issue. Would probably be helpful to see your code and how you instantiate the scenes..?

5 years later

It worked for me by making the PackedScene resource in the inspector unique.