Adding 10 seconds to countdown on collision.

Hey guys, I worked on this script a lot and it’s just really simple but it is annoying me a lot. I want to add 10 seconds to the countdown when the player collides with the game object and if the random generated number is 1.

Here is the script that is attached to the game object that the player will collide with, I searched on the forums a lot but for the life of me I couldn’t figure this out.

var powerUp : GameObject;
var number: int;
var startTime : Timer;

function Start ()
{
	powerUp = GameObject.Find("Powerup");
	number = Random.Range(1,5);
	
}

function OnTriggerEnter(col : Collider) 
{
	if(number == 1);
	{
	gameObject.GetComponent(Timer.js).startTime += 10.0;
  	}
}

And here is my timer script:

var startTime: float = 10;
var isFinishedLevel : boolean = false; 
private var displayText : String = ""; 

function Update()
{
    if (!isFinishedLevel) 
    {
       startTime -= Time.deltaTime; 
    } 

    if (startTime > 0)
    {
        var minsDisplay : String = parseInt( startTime / 60 ).ToString();
        var secsDisplay : String = parseInt( startTime ).ToString();

       if ( (startTime - ( parseInt(minsDisplay) * 60)) > 10 )
       {
         secsDisplay = parseInt( startTime - ( parseInt(minsDisplay) * 60) ).ToString();
        } 
        else 
        {
           secsDisplay = "0" + parseInt( startTime - ( parseInt(minsDisplay) * 60) ).ToString();
        }

        displayText = minsDisplay + " : " + secsDisplay;
    } 
    else 
    {
       displayText = "TIME OVER

Press Enter to restart";

       Time.timeScale = 0; 

       if (Input.GetKeyDown(KeyCode.Return)) 
       { 
            Time.timeScale = 1; 
         Application.LoadLevel(Application.loadedLevel); 
       }
    }
}

function OnGUI()
{
    GUI.Box(Rect((Screen.width / 2) - 70, 10, 140, 40), displayText);
}

some kind of guidance would be really appreciated.

Thanks,
Argen

You have to call gameobject that has timer.js script attached as component

function OnTriggerEnter(col : Collider)
{
    if(number == 1);
    {
       //gameObject.GetComponent(Timer.js).startTime += 10.0;
       var timerGo : GameObject = GameObject.Find( "timerGameObjectName" );
       timerGO.GetComponent(Timer.js).startTime += 10.0;
    }
}

Okay It works now.

FindGameObectsWithTag needs to be FindGameObjectWithTag, objects will return an array…and also the “.js” in timer.js needed to be removed.

here is the code:

var number: int;
var startTime : Timer;
var power : GameObject;


function Start ()
{
	number = Random.Range(1,2);
}

function OnTriggerEnter(col : Collider)
{
		
	power = GameObject.FindGameObjectWithTag("Wall");
    if(number == 1)
    {
       //gameObject.GetComponent(Timer.js).startTime += 10.0;

        power.GetComponent(Timer).startTime += 10.0;
    }
    else if(number == 2)
    {
    	print("Number 2");
	}
}