help with the timer... urgent please.. . :c

Do you know guys how to add a 20 seconds time bonus when my countdown timer reaches at 10? sorry guys if this question is not much a big deal; But i really need it as soon as possible so thats why i really need your help guys. God bless you all guys!
here’s my code…

//time
var startTime = 30.0;
var timer: GameObject;

function Update()
{

timeTaken = startTime - Time.time;

timer.guiText.text = FormatTime (timeTaken);

//this is the condition which is not working
if (intTime== 10);
{
timer.startTime + 30.0 ,
}
//end
}

function FormatTime (time)

{

var intTime : int = time;
var minutes : int = intTime / 60;
var seconds : int = intTime % 60;
var fraction : int = time * 10;
fraction = fraction % 10;

timeText = minutes.ToString () + “:”;
timeText = timeText + seconds.ToString ();
timeText += “:” + fraction.ToString ();
return timeText;
}

You are declaring intTime inside a function : it will be deleted once the function has finished.

So your chances to reuse and access it in another function are slim.

Put that variable outside of any function so it is accessible from all functions.

but sir why i got an error at this line?
timer.startTime += 30.0;

the error is…
Assets/Scripts/JavaScripts/Car.js(118,17): BCE0044: expecting :, found ‘+=’.

GameObject do not have a variable called startTime. You are trying to access something that doesn’t exist.

sorry sir but i really didn’t get it… :c

I am saying timer is a variable of type GameObject. It contains a GameObject. The previous link shows all variables of an object of type GameObject. And among them, there is no such thing as a variable called startTime.

var startTime = 30.0; 
var timer: GameObject;
var intTime;

function Update() 
{
	timeTaken = startTime - Time.time;
	if (timeTaken <= 10.0)
	{ 
		timeTaken += 20.0;
	}
	
	timer.guiText.text = FormatTime (timeTaken); 
} 

function FormatTime (time) 

{ 
	intTime = time; 
	var minutes : int = intTime / 60; 
	var seconds : int = intTime % 60; 
	var fraction : int = time * 10; 
	fraction = fraction % 10; 
	
	timeText = minutes.ToString () + ":"; 
	timeText = timeText + seconds.ToString (); 
	timeText += ":" + fraction.ToString (); 
	return timeText; 
}

thank you sir! It works… God bless you guys!

Be sure to use code tags when posting code - it’ll make it easier for people to read your posts.

I think I’ve posted this in reply to other threads of yours. If you’re not sure what I mean by ‘code tags’, feel free to ask.