Lerping the camera giving me an error

I am getting an error that says: Object reference not set to an instance of an object
Here is my code:
if (Input.GetButtonDown(“Fire2”))
{
Camera.main.fieldOfView = Mathf.Lerp(60f, 30f , 10f); //Here
}
if (Input.GetButtonUp(“Fire2”))
{
Camera.main.fieldOfView = Mathf.Lerp(30f, 60f, 10f); //And here
}

At first glance I see no problem with the code provided.

Remember that you can make the code a little easier to read if you use the provided tools in here

if (Input.GetButtonDown("Fire2"))
{
    Camera.main.fieldOfView = Mathf.Lerp(60f, 30f, 10f);
}
if (Input.GetButtonUp("Fire2")) 
{
    Camera.main.fieldOfView = Mathf.Lerp(30f, 60f, 10f);
}

You are most likely getting a null reference exception because there is no Camera on your scene or because your camera’s tag was modified by you or some other code

If you find yourself not finding where the camera tag is, take a look at this image:

p.s: You are not using the method Lerp as intended, the third parameter (Mathf.Lerp(60f, 30f, 10f)) should be a floating point value inbetween 0 and 1. If the provided T is outside this range, it will be clamped the same way as using mathf.clamp01