How to make a GUI Texture play an Animation of a GameObject?

I’ve created a GUITexture and would like to use it as a button. Upon clicking the button I want an animation of a GameObject to play. Seems straightforward, but I am stuck.

Here’s the JS I have attached to my GUITexture:

function OnMouseDown(){

animation.Play(“floorup”);
}

Do I have to be more specific in the code? The animation is attached to the GameObject, I assumed there would be no issues.

I would appreciate the help, for I am a noob when it comes to scripting!

Your problem is that the GUITexture has the script but it doesn’t have the animation. So what you need to do is:

create a variable to store the object to be animated in:

var other : GameObject;

then trigger the animation via the OnMouseDown() function using this:

function OnMouseDown()

{

other.animation.Play();

}