Script Works in editor but not in build

Hi, I have a script that toggles a maximum of 6 lights on and off. It works in the editor but when I build the project the light’s doesn’t turn back on.

Here is the script :

#pragma strict
public var MnScript : MainScript ;
public var go_Light1 : GameObject;
public var go_Light2 : GameObject;
public var go_Light3 : GameObject;
public var go_Light4 : GameObject;
public var go_Light5 : GameObject;
public var go_Light6 : GameObject;
public var SoundEffect : AudioClip;
public var IsOn = 0;
private var IsPlaying = 0;
private var distance = 0 ;	
private var Player : GameObject;
private var Button : Transform;

function Start() 
{
 Player = GameObject.Find("First Person Controller");
 Button = transform.Find(this.gameObject.name+"/Switch1");
}

function Update()
{ 
}

function OnMouseOver() 
{
 	distance = Vector3.Distance(transform.position, Player.transform.position);
 	if (distance < 2 )
 		{
 		MnScript.Interact = 1;
 		}
	if(Input.GetKey("e") && distance < 2 ) 
	{		
		if (IsOn == 0)
		{
			if (IsPlaying == 0)
			{	
				IsOn = 1;
				IsPlaying = 1;
				audio.PlayClipAtPoint(SoundEffect,transform.position);
				if (go_Light1 != ""){
					go_Light1.light.enabled = true;	}
				if (go_Light2 != ""){
					go_Light2.light.enabled = true;	}
				if (go_Light3 != ""){
					go_Light3.light.enabled = true;	}
				if (go_Light4 != ""){
					go_Light4.light.enabled = true;	}
				if (go_Light5 != ""){
					go_Light5.light.enabled = true;	}		
				if (go_Light6 != ""){
					go_Light6.light.enabled = true;	}		
				yield WaitForSeconds(SoundEffect.length);
				IsPlaying = 0;
				
			}	
		}
		else
		{
		if (IsOn == 1)
			{
				if (IsPlaying == 0)
				{	
					IsOn = 0;
					IsPlaying = 1;
					audio.PlayClipAtPoint(SoundEffect,transform.position);
				if (go_Light1 != ""){
					go_Light1.light.enabled = false;	}
				if (go_Light2 != ""){
					go_Light2.light.enabled = false;	}
				if (go_Light3 != ""){
					go_Light3.light.enabled = false;	}
				if (go_Light4 != ""){
					go_Light4.light.enabled = false;	}
				if (go_Light5 != ""){
					go_Light5.light.enabled = false;	}		
				if (go_Light6 != ""){
					go_Light6.light.enabled = false;	}
					yield WaitForSeconds(SoundEffect.length);
					IsPlaying = 0;	

				}	
			}
		}
	}	
}

function OnMouseExit()
{
	MnScript.Interact = 0;
}	

If you could help it would be super

You should use booleans for isOn and isPlaying vars instead of int. And you should check “if (go_Light1)” instead of “if (go_Light1 != “”)”, this will check if the gameobject is valuated.

When you launch your game, are your lights enabled at first ? And you can disable them but cannot re-enable them ?

It turns out testing the game objects by using
if (go_Light1 != “”)
doesnt work

When i used if (go_Light1) it worked.