I cannot reset my countdown timer :(

Hello, I’m 15 years old Mono-Developer from Turkey. I’m workng on Duck Shoot Project for begining but i have some issues.

There’s a code that i found from web for “Countdown”

pragma strict

		///////////////////////////////////////////////////////////
		
			var	startTime : float;
		
			var restSeconds : float;
		
			var roundedRestSeconds : int;
		
			var displaySeconds : float;
		
			var displayMinutes : float;
		
			var timeLeft : float;					
																
			static var countDownSeconds : int = 15;					
			
			var timeText : String;
																									
		///////////////////////////////////////////////////////////		
		
		function Start() 
		
		{		
			startTime = Time.deltaTime;							
		}
		
		///////////////////////////////////////////////////////////
		
		function OnGUI () 
		
		{
		
				timeLeft = Time.time - startTime;
				
				restSeconds = countDownSeconds - (timeLeft);
				
				roundedRestSeconds = Mathf.CeilToInt(restSeconds);
				
				displaySeconds = roundedRestSeconds % 60;
				
				displayMinutes = (roundedRestSeconds / 60) %60;
		
				timeText = (displayMinutes.ToString() + ":");
				
				///////////////////////////////////////////////////////////
				
				if (displaySeconds > 9)
				{
				
					timeText = timeText + displaySeconds.ToString();
				
				}
				else
				{	
				
					timeText = timeText + "0" + displaySeconds.ToString();
				
				}
				
				var textMesh : TextMesh = gameObject.GetComponent(TextMesh);
				
				textMesh.text = timeText.ToString();
				
				
				
		}

So, That’s OK.
But when i try to reset it (With Whole level);

#pragma strict

var isSaveDucks = false ;



var GameOver : GameObject;

function OnMouseDown()
{

if (isSaveDucks) {

	Application.LoadLevel(2);
}

if(!isSaveDucks) {
	
	CountPoints.Score = 0;
	
	Timer.countDownSeconds = 15;
	
	Application.LoadLevel(Application.loadedLevel);
	
	Time.timeScale = 1;
		
}

}

It is not working :frowning: Timer goes 0:0-1, 0:0-2 etc. I didn’t understand why ? Could some one explain this for me please :frowning: Thanks a lot.

(If i write something wrong sorry for my english ^_^)

Actually, I can’t see why it’s not working, but maybe instead try doing what the start function did instead of reloading. Just get a new time by using the same line of code.

Countdown script:

static var start : int = 20;
var maxStart : int = 20;
var Standingtime : int;
var seconds : int;
var minutes : int;

function Start ()
{
//start = 120;
}

function Update ()
{
Standingtime = start - Time.time;
minutes = Standingtime /60;
seconds = Standingtime %60;

if (Standingtime <= 0)
{
guiText.text = “Time Out”;
// self reset
maxStart += start;
}
else
{
guiText.text = minutes.ToString(“D2”) + “:” + seconds.ToString(“D2”);
}
if (start < maxStart)
start = maxStart;
}

In your other script just add

Countdown.start += 15;

Try resetting the startTime variable to 0