Digging technique counter

Hello, I’m making and game which has digging as it’s feature so I need timer which will count exact float (in seconds) and then destroy gameObject. This is what I tried now but it’s freezing unity:

function Update()
{

if (Input.GetMouseButtonDown(0))
{
                        digTime = 1.5; // in secounds
		          }
		          while (!Input.GetMouseButtonUp(0)) // why is this infinite loop?
		          {		          
		          digtime -= Time.deltaTime;
		          if (digtime <= 0)
		          {
		          Destroy(hit.collider.gameObject);
		          }
		}

if you want a simple timer then you can use this

function Update()
 {
 
    if (Input.GetMouseButtonDown(0))
       {
        starttimer();
       }
}


starttimer()
{\\ this will run for 20 sec don't go for syntax as no monodevelop suggestion here :)
  for(int i=0;i<20;i++)
       {
         yield return waitforsec(1);
          if(i==19)
          {
          destroy(this.gameobject);
        }
     }

}