Please use code tags Using code tags properly
Helps greatly when you give us an error and we can reference the line number on the script.
My guess, if it’s referring to the Camera.main line is you don’t have a camera in your scene tagged as MainCamera