Help with 2D AI scripting

I want to make my enemy move towards my character in the x axis, but he moves on the z axis instead. I’m not too good with scripting so here is my script and tell me what am I doing wrong.

using UnityEngine;
using System.Collections;

public class EnemyAi : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed;
	public int maxDistance;
	
	private Transform myTransform;
	
	void Awake() {
		myTransform = transform;
	}	
	
	// Use this for initialization
	void Start () {
		GameObject go = GameObject.FindGameObjectWithTag("Player");
		
		target = go.transform;
		
		maxDistance = 2;
	}		
		

	
	
	// Update is called once per frame
	void FixedUpdate () {
		Debug.DrawLine(target.position, myTransform.position, Color.yellow);
		
		//Look at target
		
		
		//Move towards target
		myTransform.position -= myTransform.forward * moveSpeed * Time.deltaTime;
	}
	
	}

forward : Shorthand for writing Vector3(0, 0, 1). Z-Axis.

Check what axis you are working with.

right : Shorthand for writing Vector3(1, 0, 0).

myTransform.position += myTransform.right * moveSpeed * Time.deltaTime; // will move in relation to the right of the transform
myTransform.position -= myTransform.right * moveSpeed * Time.deltaTime; // will move left in relation to the transform

Hi,

instead of multiplying your myTransform.position with myTransform.forward, you should multiply it with myTransform.right to go along the red axis (X). The forward member will always have the same direction as the blue axis (Z).

Read more about the Transform class here.

Best regards