Using Raycasting to Array Skybox materials/textures OnMouseButtonDown?

Hi, I have a static camera using a modified MouseOrbit script to orbit around and view my whole custom skybox, I have set up the raycasting and I get a result with OnMouseDown which is perfect, I also have a separate material array script that I have tried to incorporate into my RayCast script but to no avail, I keep getting this error message:

“MissingComponentException: There is no ‘Renderer’ attached to the “Main Camera” game object, but a script is trying to access it.
You probably need to add a Renderer to the game object “Main Camera”. Or your script needs to check if the component is attached before using it.
RayCast Button.Update () (at Assets/RayCast Button.js:17)”

What am I doing wrong?

I’m trying to click on a plane/gameobject in the 3d space that will change/array through my different sky box materials.

Can anybody help me fix my script? I have attached it below, I feel I’m so close to getting the desired result!

Thank you.

var clickable : GameObject;

var matArray : Material[]; 

private var index : int;

function Update () {

if (Input.GetButtonDown ("Fire1")) {

var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;

if (Physics.Raycast (ray, hit)) {
	index++;
   		index = index % matArray.Length;
   		renderer.material = matArray[index];
}}}

unrelated but
Physics.Raycast (ray, hit)

needs to be

Physics.Raycast (ray, out hit)

this is the problem

renderer.material = matArray[index];

its saying there isnt a renderer attached, where is this material?

right now this script is attached to the camera so basically this is what this says

Camera.Main.renderer.material = matArray[index];

That means that
Camera is a class that contains all the camera
main is part of Camera its the main camera in the scene

renderer is supposed to be something attached to the camera but its not, you know its not cause it said so.
you could try to add one

AddComponent<Renderer>();

do you need that or is that material attached to something else?
are you in fact trying to access the renderer attached to the skybox(I think so)?

if so you need to first fix the raycast then do this.

hit.renderer.material = …

Hit is the object you hit, the skybox. renderer is the renderer attached to the skybox.

Mark and comment if answered