How to rotate a object

I want to rotate my car when I either press A or D, but it doesn’t work with my code, what is the problem with my code?

var RiderSpawn : Transform;

var FinalRiderSpawn : Transform;

var Player : Transform;

var IsRiding : boolean = false;

var MovementScript : CharacterMotor;

var DrivingSpeed : float;

var DefaultPlayerRotation : Quaternion;

var GotOut : boolean = false;

var TruckCollider : Collider;

var TruckCollider2 : Collider;

var Truck : GameObject;

var IsDriving = false;

function Start () {

}

function Update () {

if(IsRiding == true){
Player.position = RiderSpawn.position;
Player.rotation = RiderSpawn.rotation;
}

else

if(IsRiding == false && GotOut == true){
Player.rotation = (DefaultPlayerRotation);
GotOut = false;
}



if(Input.GetKey(KeyCode.W) && IsRiding == true){

Truck.transform.Translate(Vector3.right * DrivingSpeed * Time.deltaTime); //The reason why I use ".right" instead of forward is because it goes to the left when I use ".forward" . So if you know how to fix this as well, it would mean a lot to me
IsDriving = true;
}

if(!Input.GetKey(KeyCode.W)){

IsDriving = false;

}

if(Input.GetKey(KeyCode.A)){

Truck.transform.Rotate(Vector3.left * DrivingSpeed * Time.deltaTime);

}

if(Input.GetKey(KeyCode.D)){ 

Truck.transform.Rotate(Vector3.back * DrivingSpeed * Time.deltaTime);

}




}

I don’t know your scale, but your are using ‘DrivingSpeed’ for both forward movement and for rotation. There should be two separate variables, or at least rotation should be a factor multiplied by ‘DrivingSpeed’. I don’t know your scale here, but typically folks build things at around a unit or two in size, which means ‘DrivingSpeed’ would be around 2.0 give or take. Your angle will be degrees per second. So if these are the kinds of values you are using, then you will only turn at two degrees per second … really slow. Try creating a turn factor and start with a value of 45. So your code could would be:

Truck.transform.Rotate(Vector3.left * DrivingSpeed * turnFactor * Time.deltaTime);