AI doesn't follow the path

Hey Guys,

I’m trying to made enemy gameobject follow the path. But It didn’t work and I couldn’t find the solution

Here is my following codes :

public class EnemyPath : MonoBehaviour
{
    [SerializeField] List<Transform> waypoints;
    [SerializeField] float enemySpeed;
    
    

    int waypointIndex = 0;
    void Start()
    {
        transform.position = waypoints[waypointIndex].transform.position;
        
    }

    // Update is called once per frame
    void Update()
    {
        EnemyMovePath();

    }

    private void EnemyMovePath()
    {
        if (waypointIndex <= waypoints.Count - 1)
        {
            var targetPosition = waypoints[waypointIndex].transform.position;
            var movementIndependenceFrame = enemySpeed * Time.deltaTime;
            transform.position = Vector2.MoveTowards(transform.position, targetPosition, movementIndependenceFrame);

            if (transform.position == targetPosition)
            {
                waypointIndex++;
            }

        }
        else
        {
            Destroy(gameObject);
        }
    }
}

https://ibb.co/98t6Cc4

I found the solution. Waypoints z axis is different than AI gameobject z axis. That’s why AI gameobject doesn’t follow the path.