Cant get my Timer to add time.

var startTime:float;
var timeRemaining:float;
var count:int = 0;
var started:boolean = true;

function Start()
{

}
function Update () 
{
 	Countdown();	
}
function Countdown()
{
	if(started == true && count == 0)
	{
		startTime = 60.0;
		count++;
	}
	
	timeRemaining = startTime - Time.time;
	ShowTime();
	if(timeRemaining < 0)
	{
		timeRemaining = 0;
		TimeIsUp();
	}
}
function ShowTime()
{
	var minutes:int;
	var seconds:int;
	var timeString:String;
	minutes = timeRemaining/60;
	seconds = timeRemaining%60;
	timeString = minutes.ToString() + ":" + seconds.ToString("D2");
	guiText.text = timeString;
}

function TimeIsUp()
{
	Application.LoadLevel("Lose Screen");
}

//script that tells timer to add time

var points:int;
var addTime: Timer;

function Start () 
{
	addTime = GameObject.Find("Timer").GetComponent(Timer);
	points = 0;
}

function Update () 
{

}

function OnTriggerEnter(Col : Collider )
{
	if(Col.gameObject.tag == "Pickup")
	{
		points += 10;
		Destroy(Col.collider.gameObject);
	}

	else if(Col.gameObject.tag == "Token")
	{
		addTime.timeRemaining += 5.0;
		Destroy(Col.collider.gameObject);
	}
}

You are calculating timeRemaining in Update()

timeRemaining = startTime - Time.time;
ShowTime();
if(timeRemaining < 0)  {
...

It doesn’t matter if you add to timeRemaining in some other script since your main script is setting the value of it in a way that overrides everything else :

// other script 
timeRemaining = 1000000000;
// main script
timeRemaining = startTime - Time.time;

You have to do one of the following (for example)

  1. add another variable to keep track of added time and use that in calculating timeRemaining timeRemaining = startTime - Time.time + addedTimes;

  2. add your += 5.0f to startTime instead

  3. count down timeRemaining with -= Time.deltaTime so you don’t completely override it at any time

Ahhh that makes sense. This solved my problem. thank you!