NULL but I can see in the Inspector that its not!

Hello. I have a prefab “AK47”. Its structure looks like this:

alt text

On the top-level of that prefab, I have a “Weapon” script. Here is how the AK47 weapon script is configured. Note the “Muzzle Flash Mount” is null, and the “Muzzle Flash” is a reference to another Prefab within my project.

alt text

When I run the game and create an AK47 unit, I can see in the inspector that it has mounted properly (note that it is a child of “Weapon Mount,” something that all of my unit prefabs have in common, so that they can all use every weapon.

alt text

Further investigation reveals that the “Muzzle Flash Mount” variable within the Weapon script, which was originally null, is no longer null. In fact, it points exactly to the Muzzle Flash Mount that it should!

alt text

But, for SOME REASON, the Weapon script keeps printing out that it is NULL when it’s called upon! (It was printing “null” in the console when I took the above photo)

I’m so frustrated, please help! It seems like it should be very simple.

The Weapon script can be found in this pastebin

I seem to be in the habit of posting questions when I’m at my wits’ end, only to solve them shortly afterwards.

In this case, I was accessing the Prefab via script, and not the correct instance. In this way, there was no additional output, but Robertbu was correct in that there was a “ghost” copy of the script in the scene.