if(!=0) unity null reference fix code example
Example: nullreferenceexception unity
// to change a variable from another script, just use this code with 1 being the
//GameObject that the script is on, 2 being the script, and 3 being the variable
GameObject.Find("1").GetComponent<2>().3 = whatever you want to change it to; ;