Help with UnityException Error

Hi, I have an error that I am getting that reads like this

“UnityException: You are not allowed to call this function when declaring a variable.”

I seem to get it whenever I plug this line of code in

var other = gameObject.GetComponent(CameraArrayPlayer);

Now it doesn’t stop me from running my game at all, but I have this piece of code in a few places, and its getting kind of annoying.

Any ideas on how to get rid of it?

Any help would be greatly appreciated! Let me know if you need further info.

Thanks again!

I am not positive, but judging by the error try declaring the variable, then in a separate line of code in the start function put,

other = gameObject.GetComponent(CameraArrayPlayer);

Hope this helps!