My controls are inverted when facing sideways.

I just started making a basic 2d top down action game. But already when implementing the basic controls something went wrong. When my character is facing sideways (my move and look keys are seperate) all my movement keys get inverted. Can anyone tell me why this is.
My code:

var speed = 2.0;

function Update () {
	if(Input.GetKey("w")) {
		transform.Translate(transform.up * speed * Time.deltaTime);
		animationController.walker.SetBool("walking", true);
	}
	else if(Input.GetKey("up")) {
		transform.rotation.eulerAngles.z = 0;
	}
	
	
	else if(Input.GetKey("a")) {
		transform.Translate(-transform.right * speed * Time.deltaTime);
		animationController.walker.SetBool("walking", true);
	}
	else if(Input.GetKey("left")) {
		transform.rotation.eulerAngles.z = 90;
	}
	
	
	else if(Input.GetKey("d")) {
		transform.Translate(transform.right * speed * Time.deltaTime);
		animationController.walker.SetBool("walking", true);
	}
	else if(Input.GetKey("right")) {
		transform.rotation.eulerAngles.z = 270;
	}
	
	
	else if(Input.GetKey("s")) {
		transform.Translate(-transform.up * speed * Time.deltaTime);
		animationController.walker.SetBool("walking", true);
	}
	else if(Input.GetKey("down")) {
		transform.rotation.eulerAngles.z = 180;
	}
	else {
		animationController.walker.SetBool("walking", false);
	}
}

Maybe your “transform.up” and “transform.right” should be “Vector3.up” and “Vector3.right” respectively?