How to follow objects in sequential order?

I want the Player follow the Ball and get it. Then with the Ball I want the Player follow the Post. I’ve done two targets to be followed sequentially but the Player skips the first target and follows the second target (Post).
Here is my code:

void Start()
    {
        transformBall = GameObject.Find("Ball").transform;
        transformPost = GameObject.Find("Post").transform;
        animator = GetComponent<Animator>();
    }
 
    void Update()
    {
        if ((transform.position - targetBall.position).magnitude > EPSILON)
        {
            animator.SetBool("IsMoving", true);
 
            Vector3 lookAtPosition = transformBall.position;
            lookAtPosition.y = transform.position.y;
            transform.LookAt(lookAtPosition);
   
            Vector3 movedirection = transform.position - targetBall.position;
            Vector3 moveSpeed = new Vector3(movedirection.normalized.x * movementSpeed * Time.deltaTime, 0, movedirection.normalized.z * movementSpeed * Time.deltaTime);
            transform.position -= moveSpeed;
        }
        else
        {
            animator.SetBool("IsMoving", false);
        }
 
 
        if ((transform.position - targetPost.position).magnitude > EPSILON)
 
        {
            animator.SetBool("IsMoving", true);
 
            Vector3 lookAtPosition = transformPost.position;
            lookAtPosition.y = transform.position.y;
            transform.LookAt(lookAtPosition);
     
            Vector3 movedirection = transform.position - targetPost.position;
            Vector3 moveSpeed = new Vector3(movedirection.normalized.x * movementSpeed * Time.deltaTime, 0, movedirection.normalized.z * movementSpeed * Time.deltaTime);
            transform.position -= moveSpeed;
        }
        else
        {
            animator.SetBool("IsMoving", false);
        }
    }
}

Any idea would be greatly appreciated…

Could you please explain this script in more details and apply it on my code above? I have no idea of how to run this script:

var doorKeys: GameObject[]; 
var openDoor: boolean; 

 function Update() 
 { 
    doorKeys = gameObject.FindGameObjectsWithTag("doorKey");

    if(doorKeys.length == 0)
    {
            openDoor = true;
    }
}