Switching Camera functions not working

Hello, I currently have my camera following my player’s movement directly. I also have an option that if my player presses “Y” then the camera will no longer follow the player’s movement and the player will be able to pan around the screen instead like league of legends. Both Camera functionalities work fine but switching from one to the other isn’t working as well. When I click “Y” the first time the camera will no longer follow my player how I want it but when I press it again it doesn’t go back to following the player. I can’t seem to understand why. Can anyone give me a helping hand? Thanks in advance!

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

public class CameraFollow : MonoBehaviour
{
    public Transform player;
    public float smoothSpeed = 0.125f;
    public Vector3 offset;
    CameraFollow cam;
    CameraController unlockedCam;
    [SerializeField]bool unlocked = false;

    private void Start()
    {
        cam = GetComponent<CameraFollow>();
        unlockedCam = GetComponent<CameraController>();
        unlockedCam.enabled = false;
    }
    private void LateUpdate()
    {
        transform.position = player.position + offset;
    }

    private void Update()
    {
        if (Input.GetButtonDown("Camera") && unlocked == false)
        {
            cam.enabled = false;
            unlockedCam.enabled = true;
            unlocked = true;
        }
        else if (Input.GetButtonDown("Camera") && unlocked == true)
        {
            cam.enabled = true;
            unlockedCam.enabled = false;
            unlocked = false;
        }
    }

}

“cam” is a reference to the current script that is running. When you disable it, this script stops executing the Update method, so you can’t enable it again. Instead of enabling and disabling the script, in late update, you can use

private void LateUpdate()
{
   if(unlocked == false)
      transform.position = player.position + offset;
}

Thank you that worked perfectly!