Delete spawned object when it reaches end of lerp: unity

so im making this thing where it smoothly transitions a newly spawned object with lerp, but i cant figure out how to delete it whenever it is done

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class makeCustomer : MonoBehaviour
{
    [SerializeField] public int maxCustomerCount = 10;
    int Customers = 0;
    float nat = 0.0f;

    [SerializeField] public GameObject customer;
    [SerializeField] public Vector3 customerSpawnPos;
    [SerializeField] public float speed = 1000f;
    [SerializeField] public List<GameObject> cusetomers = new List<GameObject>();
    [SerializeField] public Vector3 customerDespawnPos;

    Vector3 smoothMovement;
    GameObject folder;
    GameObject buyerObject;
    private void Start()
    {
        folder = new GameObject("CustomerFolder");
    }
    private void Update()
    {
       
       
            if (Customers < maxCustomerCount && Time.time > nat)
            {
                nat += 0.5F;
                buyerObject = Instantiate(customer, customerSpawnPos, Quaternion.identity);
                buyerObject.transform.parent = folder.transform;
                Customers++;
                cusetomers.Add(buyerObject);
            }

        if (buyerObject != null)
        {
            if(Time.time>1f)
            {
                if (buyerObject.transform.position.x > 4.9F)  //this is where i tried to remove it
                {
                    Debug.Log("Hello world!");
                    Destroy(buyerObject);
                    Customers--;

                }
            }
           
        }
    }
    private void FixedUpdate()
    {
        if(buyerObject != null)
        {
            foreach (GameObject buyerObject in cusetomers)
            {
                var startpos = buyerObject.transform.position;
                buyerObject.transform.position = Vector3.Lerp(startpos, customerDespawnPos, Time.deltaTime * speed);

            }
        }
    }
}

Lerp isn’t MoveTowards.

The way lerp works is (start, end, percentage), percentage being how far from start I want to be going towards end. So as a simplified example, if you inputed (0,10, 0.7f), you will get 7 from the lerp. If you inputed (50, 60,0.7f), you will get 57 from the lerp. How lerp is actually meant to be used, is the start and end are fixed points, and you adjust the percentage from 0 to 1 to get the in-between values.

In the way you are using it, you are redefining start and end, and assigning the percentage as Time.deltaTime * speed, which is more than likely less than 1 thus qualifying as a percentage. This means your object’s position is always 1-(Time.deltaTime * speed) percentage away from your intended destination, technically never reaching it. This is of course, not what Lerp was intended for, though it does produce what looks like “smoothe” movement when used this way.

The proper thing to do, would be be change to using MoveTowards instead.

If you actually like the “smoothed” movement, you will need to check the distance, and set the object to your target destination if the distance is below a certain threshold.

If you’re just flinging stuff around the screen, don’t start writing custom code unless you really need it for some reason.

Just use an existing package like LeanTween or DOTween or iTween, all free on the Asset Store.

For your problem, LeanTween has a notion of events you can listen to, such as when it finishes tweening so you can destroy it or do whatever you like.