How to reset health/energy/progress bars and how to show the ammo in numbers?

I asked that question before but I got no answer and I stuck so I need to solve that problem to continue making my game!!!

I make a third person game and I created in the game health, energy and delay bars based on this answer. I edited a bit the code so it will be fit to my game (bar for each weapon and time to fill each bar) and the bars are seeing all the time.

In the question I used for help, asked about how to reset the bar but I try to do wat the answed say and it don't works in my game.

Here is parts my code (the code is very long and you don't need to see all of it...):

//2D bars
 var basicSize : Vector2 = new Vector2(150,20);
 var otherSize : Vector2 = new Vector2(100,10);
 var healthBarDisplay : float = 100;
 var healthPos : Vector2 = new Vector2(130,60);
 var healthBarEmpty : Texture2D;
 var healthBarFull : Texture2D;
 var energyBarDisplay : float = 100;
 var energyPos : Vector2 = new Vector2(130,85);
 var energyBarEmpty : Texture2D;
 var energyBarFull : Texture2D;
 var bombBarDisplay : float = 0;
 var bombPos : Vector2 = new Vector2(80,110);
 var bombBarEmpty : Texture2D;
 var bombBarFull : Texture2D;

there are 2 more weapon based like the bombs

energyBarDisplay += Time.time * 0.0002;
     energyBarDisplay = Mathf.Clamp01(energyBarDisplay);
     bombBarDisplay += Time.time * 0.0015;
     bombBarDisplay = Mathf.Clamp01(bombBarDisplay);
     teleBarDisplay += Time.time * 0.0015;
     teleBarDisplay = Mathf.Clamp01(teleBarDisplay);
     rocketBarDisplay += Time.time * 0.0002;
     rocketBarDisplay = Mathf.Clamp01(rocketBarDisplay);

what i did for reset:

function Explode ()
     if (bombUse)
         var expEffect1 = Instantiate(bombEffect1, GameObject.Find("spawnPointA").transform.position, transform.rotation);
         yield WaitForSeconds(0.5);
         var expEffect2 = Instantiate(bombEffect2, GameObject.Find("spawnPointA").transform.position, transform.rotation);
         var ballExp = Instantiate(bombs, GameObject.Find("spawnPointA").transform.position, Quaternion.identity);
         ballExp.gameObject.tag = "CharacterProjectile";
         ballExp.rigidbody.AddForce(transform.forward * 10000);
         bombBarDisplay = 0.0f;
         //for delay
         bombUse = false;
         yield WaitForSeconds(5.0);
         bombUse = true;

to make the bars:

     // draw the background:
     GUI.BeginGroup (new Rect (bombPos.x, bombPos.y, otherSize.x, otherSize.y));
     GUI.Box (Rect (0,0, otherSize.x, otherSize.y),bombBarEmpty);
     // draw the filled-in part:
     GUI.BeginGroup (new Rect (0, 0, otherSize.x * bombBarDisplay, otherSize.y));
     GUI.Box (Rect (0,0, otherSize.x, otherSize.y),bombBarFull);
     GUI.EndGroup ();
     GUI.EndGroup ();

The problem is when I use the weapon and the delay works (there is a delay) the bar needs to show on how much time I will be able to use the weapon again, When I use it the bar reset but it filled again in notime (it flashing with the empty bar). how I can reset the bars?

Another question I want to ask is how to show by numers the bullets I have, show the ammo?

Your problem with the bar going straight back to full is that you are using Time.time. Time.time is the total time since your game started. What you want to use it Time.deltaTime. This is the length of time for this frame.

energyBarDisplay += Time.deltaTime;
energyBarDisplay = Mathf.Clamp01(energyBarDisplay);
bombBarDisplay += Time.deltaTime;
bombBarDisplay = Mathf.Clamp01(bombBarDisplay);
teleBarDisplay += Time.deltaTime;
teleBarDisplay = Mathf.Clamp01(teleBarDisplay);
rocketBarDisplay += Time.deltaTime;
rocketBarDisplay = Mathf.Clamp01(rocketBarDisplay);

By just adding Time.deltaTime to your bar it will take exactly 1 second to refill. You can make this longer or shorter by adding a scale like so.

public var energyChargeRate : float = 2;

energyBarDisplay += Time.deltaTime * energyChargeRate;

Now the energy bar will charge in half a second.

For your second question about displaying ammo. You need to add a guiText object or a textMesh object you your scene and set its text field to your ammo value.

public var ammoDisplay : TextMesh;
public var ammo : int;
public var ammoMax : int;

function Update()
    ammoDisplay.text = ammo.ToString() + "/" + ammoMax.ToString();