raise power

Hi, I have a problem.I Want to when the player hold down left mouse button ,the power of throw go up and when he release the button throw the grenade or something else with that power. can some one help me?

var curCharge : float = 0;
var maxCharge : float = 1;

var charging : boolean;

function Update()
{
   if (Input.GetMouseButtonDown(0)  !charging) {
      Charge();
   }
   if (Input.GetMouseButtonUp(0)) {
      charging = false;
   }
}

function Charge()
{
   charging = true;
   while (charging) {
      curCharge += Time.deltaTime;
      yield;
   }
}

The above should do what you’re looking for.

Basically, when the mouse button is pressed down, the function is called and charges every frame until the mouse is let up.