How to make the camera follow player forward but not backwards?

I’m working on a 2D project. I have a camera that is following the player but i would like the camera to stay at it’s current position if the player goes backwards. E.g. the player moves along the x and the camera moves with, but if the player goes back (-x), the camera stays.

Here is the code i currently have:

//following player
public bool followPlayer = true;
public Transform target;
public Vector3 offset;
public float smoothSpeed = 10f;

void FixedUpdate()
{

    if (followPlayer)
    {
        Vector3 desiredPosition = target.position + offset;
        Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
        transform.position = smoothedPosition;
       
    }

Try this one :

    public bool followPlayer = true;
    public Transform target;
    public Vector3 offset;
    public float smoothSpeed = 10f;
    private Vector3 lastPos = Vector3.zero;
    private void Awake()
    {
        lastPos = transform.position;
    }
    void FixedUpdate()
    {
        if (followPlayer && (target.position - lastPos).x > 0)
        {
            Vector3 desiredPosition = target.position + offset;
            Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
            transform.position = smoothedPosition;
            lastPos = transform.position;
        }
    }