Why does GameObject.Find() work in ones and not in others?

That’s the point:
I have a list of gameObjects called “Diana”. When I firstly use :


It works perfectly. But then, when I call:


it shows me a NullReferenceException:

NullReferenceException: Object
reference not set to an instance of an

Here’s an image of my code and the Hierarchy.

Can anybody help me?

Thank in advance!

although you’ve combined it with the hierarchy screenshot, when posting code, please paste it and format appropriately. if somebody helping you needs to include it, they’re unlikely to type it in.

that said, i believe your problem is that when you disable a game object, Find will no longer, err, find it - because it’s no longer active. in order to achieve this functionality, store a reference in Awake() or Start() and use it when necessary.

it’s a good idea to check for null before accessing it too…