My Tank script is not working 100%.Plase help if you can^^.

HI I mad this script for a tank:

var flWheelCollider:WheelCollider;
var frWheelCollider:WheelCollider;
var rlWheelCollider:WheelCollider;
var rrWheelCollider:WheelCollider;

var currentSpeed:float = 0.0;
var maxTorque=260.0;
var maxSpeed:float = 70.0;
var reversmaxSpeed:float=-70.0;






//---------------------------------------------------------------------------------------------------------------------------------------------------------
function  FixedUpdate () {

flWheel();
frWheel();
rlWheel();
rrWheel();
	
	 currentSpeed=((flWheelCollider.radius*Mathf.PI*2)*flWheelCollider.rpm*60/1000);
	 currentSpeed=Mathf.Round(currentSpeed);
	 
}

//---------------------------------------------------------------------------------------------------------------------------------------------------------
function flWheel(){

	if (currentSpeed<maxSpeed&currentSpeed>reversmaxSpeed&Input.GetKey(KeyCode.F)){
		 flWheelCollider.motorTorque=maxTorque;
		 rlWheelCollider.motorTorque=maxTorque;
	}
	
	
		
	else {
		 flWheelCollider.motorTorque=0.0;
		 rlWheelCollider.motorTorque=0.0;
	}
}
	
function frWheel(){

	if(currentSpeed<maxSpeed&currentSpeed>reversmaxSpeed&Input.GetKey(KeyCode.H)){
		 frWheelCollider.motorTorque=maxTorque;
		 rrWheelCollider.motorTorque=maxTorque;
	}

	else {
		 frWheelCollider.motorTorque=0.0;
		 rrWheelCollider.motorTorque=0.0;
	}


}

function rlWheel(){
	if(currentSpeed<maxSpeed&currentSpeed>reversmaxSpeed&Input.GetKey(KeyCode.C)){
		 rlWheelCollider.motorTorque=-maxTorque;
		 flWheelCollider.motorTorque=-maxTorque;
	}

	else {
		 rlWheelCollider.motorTorque=0.0;
		 flWheelCollider.motorTorque=0.0;
	}





}


function rrWheel(){

	if(currentSpeed<maxSpeed&currentSpeed>reversmaxSpeed&Input.GetKey(KeyCode.B)){
		 rrWheelCollider.motorTorque=-maxTorque;
		 frWheelCollider.motorTorque=-maxTorque;
	}

	else {
		 rrWheelCollider.motorTorque=0.0;
		 frWheelCollider.motorTorque=0.0;
	}
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------

My goal is:when I press"F" the the left track pushes forward
when I press"H" the the right track pushes forward
when I press"C" the the left track pushes back
when I press"B" the the right track pushes back

My problem is:when I press"F" nothing happens
when I press"H" nothing happens
when I press"C" the front and rear left Wheel Colliders pushes back
when I press "B"the front and rear right Wheel Colliders pushes back

If some one could look at this and PLEASE could help me,I would be wary grate full.
Thanks

Hello there!

The problem is that you set your torque to 0 if the if-statement fails. Should the F or H statements succeed the wheels will be immideatly reset to 0 as soon as C and B fails. The reason C and B succeeds is because they are placed after F and H.

Hey Thanks,
Can you maybe also give me an idea how to fix this,so that it works?

Eh I’ve told you exactly what the problem is, but sure I guess. It’s not a major task.

function FixedUpdate()
{
    Left();
    Right();
}

function Left()
{
    if (currentSpeed<maxSpeed&currentSpeed>reversmaxSpeed) {
        if(Input.GetKey(KeyCode.F)) {
            flWheelCollider.motorTorque=maxTorque;
	    rlWheelCollider.motorTorque=maxTorque;
        }
        else if(Input.GetKey(KeyCode.C)) {
		 flWheelCollider.motorTorque=-maxTorque;
		 rlWheelCollider.motorTorque=-maxTorque;
	}
        else {
		 flWheelCollider.motorTorque=0.0;
		 rlWheelCollider.motorTorque=0.0;
	}
    }
}

There you go. The Right() function would be the same as Left(), but change what wheels are affected and what input key you use.

Hey,THANKS a 1000 Times!!!
It works realy nice,now I just have to aply brakes,which I should be able to do on my own^^.
Also I apologize for that late answer.It was just crathy,first the Internet broke down and than eaven the Electricity went out:(.
So again many Thanks and I hope that one day,when I have learnd Programming I can help you:)