How Do I Have An Increasing Value When I Hold A Key Down?

At the moment i have been playing around with “moving stuff forward” with script.
I have imported a car model into my scene and attached the script to it, so now i can press “W” to go forward and “S” to go backward.

So the question is…

How do i make the car slowly speed up to the top speed after a certain amount of time, and slowly slow down when the “W” key is let go?

You will have to define an axis with W and S and access the value with Input.GetAxis().
http://unity3d.com/support/documentation/ScriptReference/Input.GetAxis.html
http://unity3d.com/support/documentation/Manual/Input.html

Input.GetButtonXX() methods return a boolean value, whereas Input.GetAxis() returns a floating value in range [-1,1].

Use an acceleration value, which you will add to the speed over time, when the W button is pressed. Add the acceleration, until a maximum speed is reached.

When the W button is released you use the same or another acceleration value and subtract it from the speed, until zero is reached.

Over time means that every frame you apply the acceleration according to the frame time.

I created this when I was trying to get used to movement controlls.
It speeds up to a max speed, when the w button is held down.

var ShipTopSpeed:float = 15;
var RevShipTopSpeed:float = -10;
var ShipAcceleration:float = 5;
var ShipDecceleration:float = 1.5;
function Update () {

 if(Input.GetButton('w') && (ShipCurrentSpeed < ShipTopSpeed )) {
 NewSpeed = ShipCurrentSpeed + ShipAcceleration;
 ShipCurrentSpeed = NewSpeed;
}

 if (Input.GetButton('s') && (ShipCurrentSpeed > RevShipTopSpeed )){
 NewSpeed = ShipCurrentSpeed - ShipDecceleration;
 ShipCurrentSpeed = NewSpeed;
 }

 if (ShipCurrentSpeed > 0){
 transform.Translate(Vector3.forward * Time.deltaTime * ShipCurrentSpeed );
  
 }
if (ShipCurrentSpeed < 0) {
transform.Translate(Vector3.forward * Time.deltaTime * ShipCurrentSpeed );
 }

It was designed as a space simulator, so the forward velocity is constnantly applied, you can add drag to slow it down.

Hope it helps.