Trouble in making enemy follow player.

Hello, I have a script which is attached to enemy in order to make them to follow player.This is working fine only for sphere but not for cube.I mean sphere is following player but not cube. Cube is just coming to player’s position and then not moving at all.Can somebody tell where I went wrong.

Thanks.

This is script:

public GameObject prefab;
public GameObject target;
public float moveSpeed;
public float rotationSpeed;

void Start() {
	
} 

void Update () {
	

	transform.position = Vector3.MoveTowards(transform.position, target.transform.position, moveSpeed * Time.deltaTime);
	Vector3 vectorToTarget = target.transform.position - transform.position;
	float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg;
	Quaternion qt = Quaternion.AngleAxis(angle, Vector3.forward);
	transform.rotation = Quaternion.RotateTowards(transform.rotation, qt, Time.deltaTime * rotationSpeed);
}

you use the Navigation for the enemy and also use Navemash Agent on enemy . its automatically follow the player. where player move in your game environment