3rd person movement?

I need some help I’m making a 3rd person RPG and I need some help with movement.
I wanna make a game similar to Kingdom Hearts and the movement is killing me. Whenever I walk, when using my own made scipt, I can walk straight but when I turn, camera turns fine but I’m still walking in the straight Z axis and when I turn I can only turn 180 degrees on the Z axis so I can only turn around behind me and stops
This is my own made JavaScript:

var Speed = 5;
var Turning = 5;

function Update ()
{
var pos = transform.position;
var rot = transform.localRotation;
if (Input.GetKey(KeyCode.W))
{
pos.z += Speed * Time.deltaTime;
transform.position = pos;
}
if (Input.GetKey(KeyCode.S))
{
pos.z -= Speed * Time.deltaTime;
transform.position = pos;
}
if(Input.GetKey(KeyCode.A))
{
rot.y -= Turning * Time.deltaTime;
transform.localRotation = rot;
}
if(Input.GetKey(KeyCode.D))
{
rot.y += Turning * Time.deltaTime;
transform.localRotation = rot;
}
}

I tried using the FPS walker script by itself and all it does is moves properly but I wanna change moving left and right to the rotation of my object to go left and right.

HOW DO I DO THIS!!??

please help me :cry:

Try this:

var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;
var rotateSpeed = 90;

private var moveDirection = Vector3.zero;
private var grounded : boolean = false;

function FixedUpdate() {
	if (grounded) {
		// We are grounded, so recalculate movedirection directly from axes
		moveDirection = new Vector3(0, 0, Input.GetAxis("Vertical"));

		moveDirection = transform.TransformDirection(moveDirection);
		moveDirection *= speed;
		
		if (Input.GetButton ("Jump")) {
			moveDirection.y = jumpSpeed;
		}
	}

	// Apply gravity
	moveDirection.y -= gravity * Time.deltaTime;
	
	// Move the controller
	var controller : CharacterController = GetComponent(CharacterController);
	var flags = controller.Move(moveDirection * Time.deltaTime);
       transform.Rotate(0, rotateSpeed * Time.deltaTime * Input.GetAxis("Horizontal"), 0);
	grounded = (flags  CollisionFlags.CollidedBelow) != 0;
}

@script RequireComponent(CharacterController)

For movement, it is almost always better to use GetAxis() than GetKey when there is a positive and negative direction.

OMG!!!
Thank you so much!!! This is exactly what I was looking for :3