Enable and disable one button from a Static Var?

Hello Everyone,

I’m trying to enable and disable one button from a Static var in other script.

please take a look to my script

Any advice is more than welcome.

Thanks in advance!

static var triggerGo : int; //Activate Tool.
static var cameraGo : int; //Activate Camera.
var Skin_tool : GUISkin;
var beep : AudioClip;

GUI.enabled = true; 

	function Update(){
    if (animations.batteryGo == 1 ){  
    GUI.enabled = false;
 
 
    if (animations.batteryBack == 1 ){  
    GUI.enabled = true;
     
  }
}
}
 

function OnGUI (){
  	GUI.skin = Skin_tool;
	if (GUI.Button(Rect(870,345,80,80),"")){
	audio.PlayOneShot(beep);
   	triggerGo = 1; //Activate Tool.
  	cameraGo = 1; //Activate Camera.	
 	}	
}

@script RequireComponent(AudioSource)

GUI.Enabled is intended to be used in the OnGUI() function – The idea is that you set GUI.Enabled to false right before the code that draws the button, then set GUI.Enabled back to true right after that code. This will cause all of the code between when you set it to enabled/disabled will be disabled – Perhaps this example will clear things up:

public function OnGUI()
{
	//These buttons will be enabled
	GUI.Enabled = true;
	GUI.Button(...);
	GUI.Button(...);
	GUI.Button(...);
	
	
	
	
	//These buttons will not be enabled
	GUI.Enabled = false;
	GUI.Button(...);
	GUI.Button(...);
	GUI.Button(...);
	
	
	
	//This button will only be enabled if animations.batteryGo == 1
	GUI.Enabled = animations.batteryGo == 1;
	GUI.Button(...);
	
	
	//These buttons will be enabled
	GUI.Enabled = true;
	GUI.Button(...);
	GUI.Button(...);
	GUI.Button(...);
}