How to create a timer code.

I can't create a timer code for my prank game. Whenever I try something new I get errors or it does not work. Please help my game.

Try This:

private var timeLeft: float = 0;
var totalTime: float = 3;

function Start()
{
     timeLeft = totalTime;
}

function Update()
{
     timeLeft -= time.deltaTime;
     if(timeLeft < 0)
     {
          //Do what you want here when time runs out.
          //if you want it to repeat itself over and over add keep the next line
          timeLeft = totalTime;
          //if you do not want it to repeat delete the line above.
     }
}