Change cube texture script

Hi! As i said many times, i am a beginner at scripting. I am starting to understand things, but i only know the basics =P

So, i was asking myself: I need to learn! How am i going to finish a game if i can’t make scripts for it? So, i created a new project ONLY to train my skills. I made a very nice “computer sim”. Currently you can look around your desk and turn on the pc. But i want to make a “texture changer script” and i don’t know how =/

Is it possible to make a script that can CHANGE some specific cubes’ textures when you click on it using the mouse?

Here’s the script i have for now. (I know, it’s ridiculous but i made it just to test if it work)

#pragma strict

function OnMouseUp()
{
    Debug.Log("The system started");
}

It displays a message on the console when the player click on the “START” button. When the player press the start button, i want a cube to change it’s texture. Actually, more than one cube. I have some things in mind,like… i know that i need to use variables so i can select the cubes more easily, but the thing about change the textures…

// find your cube in the scene and assign it to a variable
var cube1:GameObject;
cube1=gameObject.Find(“the name of your cube here”);

 //leave a space in the inspector where you can drag and drop animage
        
     var sometexture:Texture2D;
         if (!sometexture){sometexture=new Texture2D(2,2);}
     
     // this is the line to change the texture of an object!!!
     // put this line wherever you want the change to happen!!!
     
     cube1.transform.renderer.material.mainTexture=sometexture;