NullReference with trigger C# ?

Hi,

I don’t understand why I get this error in my code :

NullReferenceException: Object reference not set to an instance of an object
CornerIA1.OnTriggerEnter

After the collision, triggerOn = true should be sent to the IAParent script,
the scripts are well connected to their gameObject,
I also tried with GetComponent<> or transform.GetComponent… but still the same thing.

Here is the code :

//IAParent scr;

void Start () { }

void Update () { }

void OnTriggerEnter ( Collider other ) {
	IAParent scr = other.GetComponent("IAParent") as IAParent;
	scr.triggerOn = true;//null reference 
}

Would you know why?

Thanks

not tested

what happens if you use something like this?

//IAParent scr;
 
void Start () { }
 
void Update () { }
 
void OnTriggerEnter ( Collider other ) {
IAParent scr = other.gameObject.GetComponent("IAParent") as IAParent;
scr.triggerOn = true;//null reference
}