inherits error of camera while calling in script.

I am instantiating obtecs tin for loop.
Using AddComponenti am attaching a script

I declared

private Camera camera;

In start function i given

camera = GameObject.Find("Main Camera").GetComponent<Camera>();

I am getting a warning

Assets/Scripts/buttonScript.cs(63,24): warning CS0108:' hides inherited member’. Use the new keyword if hiding was intended

First of all it’s not an error, it’s a warning.

Since your script is derived from MonoBehaviour your class already has a member called “camera”. This member (inherited from Component) returns the Camera component that is attached to the same GameObject as your script. If there is no Camera it returns null.

You named your variable also “camera”. That will hide the member that is already there. If you don’t need the camera property of Component you can use the new keyword when declaring the variable:

    private new Camera camera;

However it’s better to just use a different name:

    private Camera mainCam;