Energy limit for my ship booster script

Hello guys, I’m here once again to ask for help, because I’m terrible at Unity scripting :frowning:

So basically my ship has a boost script that when I press and hold the spacebar, its movement speed is multiplied. Now I want a way to limit this boost as it will be overbalance if the player could just boost forever. So I want some sort of energy variable which gets consumed while boost is active.

1 second of boost = 25 energy;
Energy out of 100;
It will take some [variable] time to recharge this energy, lets say 5 energy per 10 seconds.
If the energy is 0, the recharge time is double.

My boost script

 if (Input.GetKey("space"))
    			{
    			GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = true;
    			rigidbody.AddForce(inputMovement*acc,ForceMode.Force);
    			print(moveSpeed);
    			}
    		if(Input.GetKeyUp("space"))
    		{
    			GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = false;
    		}
    	}

Cheers guys,

// Needs to be outside any functions/ methods

var maxBooster : float = 0.0;  // this can be set to any number here or in the inspector.
private var curBooster : float = 0.0; // this is hidden from the inspector and used internally only.

// Needs to be in update function

if (Input.GetKey("space") )
{ 
    if(curBooster > 0)
    {
          GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = true;             

          rigidbody.AddForce(inputMovement*acc,ForceMode.Force);

          print(moveSpeed); 

          curBooster -= (1 * Time.deltaTime); // this will make curBooster decrease by 1 full unit per second.
     }
}

if(curBooster <= (maxBooster)) // this needs to be in the Update() function
{
     curBooster += (1 * Time.deltaTime) // same as above except it will increase.
}

if(Input.GetKeyUp("space"))
{
     GameObject.FindGameObjectWithTag("Thruster").renderer.enabled = false; 

      
}

// ------------------------------------------------------------------------------------