Change lane of vehicle when hold left mouse

Sorry for my bad english but i have some question.
I’m making a racing game with 2 lanes. Now I want the car to move forward in a straight line and when I hold down the left mouse button, the car will start moving gradually to the left (second lane). 2) and when the object moves to the middle of the 2nd lane, it will move in a straight line. When you release the left mouse button, the car will gradually move back to the first lane. I tried doing this but it doesn’t work.

using UnityEngine;

public class Move : MonoBehaviour
{
    private Rigidbody rb;
    public float speed;
    private Vector3 dir;
    private bool goLeft;
    private bool goRight;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        dir = Vector3.forward;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            dir = new Vector3(-1f, 0, 1f);
            return;
        }

        if (Input.GetMouseButtonUp(0))
        {
            dir = new Vector3(1f, 0, 1f);
            return;
        }
        if (transform.position.x > -4f && transform.position.x < -2f)
        {
            dir = Vector3.forward;
        }
    }
    private void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0))
        {
            dir = new Vector3(-1f, 0, 1f);
            if(transform.position.x > -4f && transform.position.x < -2f)
            {
                dir = Vector3.forward;
            }
            rb.velocity = dir * Time.fixedDeltaTime * speed;
            return;
        }

        if (Input.GetMouseButtonUp(0))
        {
            dir = new Vector3(1f, 0, 1f);
            return;
        }
        if (transform.position.x > -1f && transform.position.x < 1f)
        {
            dir = Vector3.forward;
            rb.velocity = dir * Time.fixedDeltaTime * speed;
        }
    }
}

I think you may have the wrong section of the forums. This is for Visual Scripting in Unity, not coding. You may get help here, but there aren’t nearly as many active people in this part of the forums.

Edit: One quick thing that may help you, you’ve got Input.GetMouseButtonDown/Up in your FixedUpdate, that may be bad. In my experience, you’d put that into your Update, then set a variable that you check in your FixedUpdate.

Thank u