Limiting the speed of my car

Hi,
I’ve searched everywhere but didnt get an answer for this, how do I limit the speed of my car? my if statement doesnt work in function Update().
My code:

function Update() {
	if (currentSpeed > topSpeed) {
      maxTorque = 0;
      } else if (currentSpeed <= topSpeed) {
      maxTorque = maxCurrentTorque;
      } else {
      Decel();
      } 
}         

maxTorque is my variable to hold the motorTorque of my WheelColliders, and maxCurrentTorque is a variable whose value is taken by the maxTorque after the speed is below the limit.
Thanks

Ok, so now I kinda solved my own problem, but just one more thing, my car accelerates even after I set my motor torque to 0. How can I stop that from happening?
And sorry if I haven’t mentioned it earlier, I am using Touch controls with GUI buttons to accelerate and brake.