disappear script that last a certain amount of time

i have created a guitext that i have programmed to turn off when i press one of two different buttons. they both turn it off for as long as i hold that button, so if i dont it will just flash off then on again. My problem is that for one of the two key commands i need a timer the tell it how long to shut off for. I believe i am very close to the final script i just am not sure what i need to do. Im pretty sure i need to set another var or two but not entirely. Any and All help is appreciated!

Normal script:

var go : GameObject;

function Update () {
    
    go.SetActive(!Input.GetKey(KeyCode.LeftShift));
    go.SetActive(!Input.GetKey(KeyCode.R));
}

My FAIL edit:

var go : GameObject;

function Update () {
    
    go.SetActive(!Input.GetKey(KeyCode.LeftShift));
    
    if(Input.GetKey(KeyCode.R)){
    Reload();
    }
}

function Reload () {
		go.SetActive(!Input.GetKey(KeyCode.R)) = true;
		yield WaitForSeconds(2);
		go.SetActive(Input.GetKey(KeyCode.R)) = false;
}

The problem was that when you released ‘R’, ‘LeftShift’ was not pressed so the guiText was set to active. This should work better:

#pragma strict
var hiddenTime = 2;
var releaseTime = 0;

function Start () {

}

function Update () {

	if (Input.GetKey(KeyCode.LeftShift)) {
		gameObject.guiText.enabled = false;
		releaseTime = -hiddenTime;
	}
	
	if (Input.GetKey(KeyCode.R)) {
		gameObject.guiText.enabled = false;
		releaseTime = Time.time;
	}
	
	if ( Time.time - releaseTime >= hiddenTime ) {
		gameObject.guiText.enabled = true;

You can set a timer using time.deltaTime * 1.

function Update()
{
  go.SetActive(!Input.GetKey(KeyCode.LeftShift));
    
  if(Input.GetKey(KeyCode.R))
  {
    timer = 0;  // this will set the timer variable to 0 as long as R is pressed
  }

  if (timer < visibilityTimer)
  {
    go.SetActive(false);
    timer += (time.deltaTime * 1); // if the timer variable is less than visibility timer variable it will increase 1 unit per second.
  }
  else
  {
    go.SetActive(true);
  }
}

For this to work you will need to set up 2 variables:

private var timer : float;
var visibilityTimer : int;

the timer variable must be a float or it won’t work, the visability timer variable can be float or int; also if you set visibility timer to public you can customize the timing from the inspector.