Having trouble with a 'lerp' script?

Hi
I have a script that should toggle my camera from point A to point B when the input ‘SwitchShoulders’ is pressed.

Here’s the script:

public class TogglePosition : MonoBehaviour
{
    public Vector3 leftPosition = new Vector3(-4177.642f, -3220.743f, 6346.121f);
    public Vector3 rightPosition = new Vector3(5159.432f, -3220.743f, 5764.928f);
    public float speed = 1000f;
   
    void Update()
    {
        if (Input.anyKeyDown)
            movingToRightPosition = !movingToRightPosition; // Go towards other position.
        Vector3 targetPosition = movingToRightPosition ? rightPosition : leftPosition;
        transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
    }
   
    bool movingToRightPosition;
}

But I keep getting the error:
“Assets/SwitchShoulders.cs(1,31): error CS0246: The type or namespace name `MonoBehaviour’ could not be found. Are you missing a using directive or an assembly reference?”

How do I fix this?

You’re missing the UnityEngine namespace. Add the following line to the top of your code:

using UnityEngine;

// declare your class here

Also, the bool movingToRightPosition should be declared before Update.