Car Script error C#

Hello guys I was trying to make a script for my car in my game but every time my car rotates it goes sideways like if the z axis didn’t rotate with the object

the script goes like this:

using UnityEngine;
using System.Collections;

public class CarControl : MonoBehaviour {
	
	public bool Driveble = false;
	public bool isTouching = true;
	public float MaxAcelerationForwards = 0.0f;
	public float MaxAcelerationBackwards = 0.0f;
	private float currentacelerationF = 0.0f;
	private float currentacelerationB = 0.0f;
	       
	       private float Px;
	 	   private float Py;
		   private float Pz;
	       private bool AceleratingForwards = false;
	       private bool AceleratingBackwards = false;
	
	void Update () {
	if(Driveble){
			if(Input.GetKey(KeyCode.W))
			{
		   Px = transform.position.x;
	 	   Py = transform.position.y;
		   Pz = transform.position.z;
				if(isTouching){
					if(currentacelerationF < MaxAcelerationForwards){
						currentacelerationF ++;
						transform.position = new Vector3(Px, Py, Pz += currentacelerationF * Time.deltaTime);
						}
				else{}
				}
				
				else{}
				
			}
			else{
			if(Input.GetKey(KeyCode.S))
			{
		   Px = transform.position.x;
	 	   Py = transform.position.y;
		   Pz = transform.position.z;
					if(isTouching){
						if(currentacelerationB < MaxAcelerationBackwards){
						currentacelerationB++;	
				transform.position = new Vector3(Px,Py,Pz -= currentacelerationB * Time.deltaTime);
							bool AceleratingForwards = true;
					}
					else{}
					}
					else{}
			}
				else{
			if(Input.GetKey(KeyCode.A))
			{
			}
					else{
			if(Input.GetKey(KeyCode.D))
			{
					
			}
						else{
							if(AceleratingForwards == false){
								if(currentacelerationF < MaxAcelerationForwards){
									if(currentacelerationF > 0.0f){
		   Px = transform.position.x;
	 	   Py = transform.position.y;
		   Pz = transform.position.z;
										currentacelerationF--;	
				transform.position = new Vector3(Px,Py,Pz += currentacelerationF * Time.deltaTime);}
								}
								else{
									if(currentacelerationF == MaxAcelerationForwards){
										if(currentacelerationF > 0.0f){
		   Px = transform.position.x;
	 	   Py = transform.position.y;
		   Pz = transform.position.z;
										currentacelerationF--;	
				transform.position = new Vector3(Px,Py,Pz += currentacelerationF * Time.deltaTime);}
									}
								}
							}
							else{
								if(AceleratingForwards == false){
								if(currentacelerationB < MaxAcelerationBackwards){
									
								}
								else{
									if(currentacelerationB == MaxAcelerationBackwards){
										
									}
								}}
							}
						}
					}
				}
			}
		}
		
	}
}

if you guys could help me I would be grateful.

By the way I haven’t finished yet so there’s stuff missing.

Well, there’s absolutely no rotate code there and the rotation won’t change unless you change it. Check transform.rotation.

Thank you all but i figured out how to do its just change the lines were I wrote

transform.position = new Vector3(Px,Py,Pz += currentacelerationF * Time.deltaTime);}

to

transform.Translate(Vector3.forward * currentacelerationF * Time.deltaTime);

but still thanks for your help!