GUI fuel gauge based on time button is held down

I need to make a GUI fuel gauge script that will deplete the “amount of fuel” a certain amount or percent per second the space bar is held down. any help would be appreciated :slight_smile:

Hi,

There may be errors, but try this one out. Press space and it takes away fuel.

It might give you a rough idea to be able to review your question and to be more specific.

var fuel:int = 1000;
var efficiency:float = 1.0;


function Update()
{
if(Input.GetKey("space")
{
fuel = fuel - efficiency;
}
}

function OnGui()
{
GUI.Label(new Rect(10,10,100,30),fuel);
}