Camera.main will return null if there isn't an enabled camera tagged as MainCamera.
Camera.main
null
Tag the enabled camera in your scene you intended to find using the built-in MainCamera tag.