error in flashlight script

Hey mean how to create Energy Bar? :open_mouth: for Flashlight

  var lightSource : Light;
var FlashLightSound : AudioClip;
private static var energy : float = 100;
private static var turnedOn : boolean = false;
var drainSpeed : float = 0.4;

function Update ()
{
	if (Input.GetKeyDown(KeyCode.F)) ToggleFlashlight();
	
		if (Input.GetKeyDown(KeyCode.F))
		{
			audio.PlayOneShot(FlashLightSound);
		
		}

}

function ToggleFlashlight ()
{
	turnedOn =!turnedOn;
	if (turnedOn  energy > 0)
	{
		TurnOnAndDrainEnergy();
	}
	else
	{
		lightSource.enabled = false;
	
	}

}

function TurnOnAndDrainEnergy ()
{
	lightSource.enabled = true;
	
	while (turnedOn  energy > 0) {
		energy -= drainSpeed*Time.deltaTime;
		yield;
}
	lightSource.enabled = false;
}

static function AlterEnergy (amount : int)
{
	energy = Mathf.Clamp(energy+amount, 0, 100);

}

there are lots of ways of doing it… if you google “unity health bar” you’ll find lots of solutions of how to represent a value as a bar.