Modify Rigidbody Speed

How would I modify my rigidbody's speed? I have a tank using WheelColliders that can chug along towards you. The problem is, it can't climb hills. I have a script to fix that. It speeds up the tank if it slows down while trying to climb a hill, and catches it if its going too fast.

var speed = Rigidbody.velocity;
var maxSpeed;
var minSpeed;

function Update () {
if (speed < minSpeed) 
    {
        motorTorque ++;
    }

if (speed > maxSpeed)
    {
        motorTorque --;
    }
}

However, this script needs fixing. What's wrong?

P.S. It gives this error message: "An instance of type 'UnityEngine.Rigidbody' is required to access non static member 'velocity'."

Several things are wrong...mainly, Rigidbody.velocity is a Vector3, which you can't change with ++ or --; you have to say what member(s) of Vector3 exactly you want to change. You may have been thinking of Rigidbody.velocity.magnitude, but that's read-only. So you need to change the entire Vector3.

Two, you've assigned Rigidbody.velocity to a variable called speed, which even if you were modifying correctly, you're doing nothing with it. Changing the speed variable won't have any effect on the velocity.

Three, even if that code did work, it's framerate-dependent, where what happens will happen at different rates as the framerate goes up and down, and on different machines.

Four, while it's not exactly wrong, you have minSpeed and maxSpeed as dynamic variables for no good reason, which will work, but slowly. You should specify the type or let the compiler infer it. (i.e., var minSpeed = 10.0;)

var speed = Rigidbody.velocity.magnitude;
var maxSpeed:float=40;
var minSpeed:float=10;

function Update () {
if (speed < minSpeed) 
    {
        speed ++;
    }

if (speed > maxSpeed)
    {
   speed --;
    }
}