Problem with timer script

Hi all i am having a problem where i looked at for the last few days but i really cannot find out what is wrong. I don’t have a clue anymore. I already tried to change a lot but nothing helps.

I have a timer scripts which keeps track of the time during the game. In it is a variable named “looptscript” which is changed outside the timerscript to stop the timer when the player is gameover or returns to the menu etc.

The problem is that the script runs but now after 30 seconds instead of counting on to 31, 32, 33 etc. I makes the time 1.30 so it counts on a whole minut.

Below is my timer script. Other scripts read the time stamp it generates and adjust game difficulty to it.

import System; 
 
 
var startTime: float;
var printtext: String; 


var guiTime : float;
var timemins : float;
var timesec : float;

var looptscript : boolean = true;

function Update () {
 
    guiTime += Time.deltaTime;
    
    timemins = guiTime / 60;
    timesec = guiTime % 60;
    
    printtext = String.Format ("{0:00}:{1:00}", timemins, timesec); 
	}
	
	
if (looptscript == false) {
	guiTime = 0.0; 
}   





function OnGUI() {

 GUI.Label (Rect (10, 10, 100, 20), printtext);

}

Try this one.

The Code:

var min : int;
var sec : int;
var fraction : int;
var timecount : float;
var starttime : float;
var timeCounter : GUIText;

function Start ()
{
starttime = Time.time;
}

function Update () {
timecount = Time.time - starttime;
min = (timecount/60f);
sec = (timecount % 60f);
fraction = ((timecount * 10) %10);
timeCounter.text = String.Format("{0:00}:{1:00}:{2:00}",min,sec,fraction);
}

You might want to check out this answer. I am not really sure what is causing the issue for you.