NullReferenceException on foreach Gameobject go in gos loop

Hello

I have this simple problem:
on a function, I look for all the instances with the same tag.
Then, I want to access to one of their scripts in order to check a boolean inside.

I always get:
NullReferenceException: Object reference not set to an instance of an object.

any help??

Than you

                GameObject[] gos = GameObject.FindGameObjectsWithTag ("NaveProxy");

       
                foreach (GameObject go in gos) {

                        bool bai = go.GetComponent<naveProxyController> ().isActive ();

                        if (bai) {
                                       GameObject l = Instantiate (line, transform.position, Quaternion.identity) as GameObject;
                                l.GetComponent<LineScr> ().setParams (gameObject, go);
                                l.transform.parent = transform;
                        }
                }

What line has the null reference?

line 6. Exactly when calling the script.

I have checked and all the instances of the prefab have script…

I would double check that you actually have GOs tagged with NaveProxy.
Next I would double check that those GOs actually have the naveProxyController script, which you said you already did.
Maybe the naveProxyController script is on a child of go? If so use GetComponentInChildren.

Thats all I can think of.