Player not moving in the right direction instantly

Okay, so here is the deal.

I’ve created a script to try and recreate the Infinite Runner. The script should tell the player to move 90 degrees to the left when it is moving forward and 90 degrees to the right when it is moving to the left. That is kinda working but the thing is, which ever input I use, sometimes it just doesn’t register correctly. It responds for a millisecond but doesn’t go the right way all the way. I tried putting it in FixedUpdate and Update but nothing seems to work. It’s a weird question maybe so sorry for that.

I hope someone can help me out here.

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

public class PlayerScript : MonoBehaviour {

    public float speed;

    private Vector3 dir;


    void Start ()
    {
        dir = Vector3.zero;
    }

    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            if (dir == Vector3.forward)
            {
                dir = Vector3.left;
            }
            else
            {
                dir = Vector3.forward;
            }
        }

        float amountToMove = speed * Time.deltaTime;

        transform.Translate(dir * amountToMove);
            

            
    }
}

Look at this line:

if (Input.GetMouseButton(0))

and make it look like that:

if (Input.GetMouseButtonDown(0))