Trigger animation from a GUI button?

I am having no problems triggering an animation with a collision, but can't quite work out how to trigger an animation from a GUI button click. Thanks!

Script used:

 var mainmenuSkin : GUISkin;

function OnGUI ()
{ = mainmenuSkin;

    var ScreenX : int = 10;
    var ScreenY : int = 10;
    var areaWidth : int = 100;
    var areaHeight : int = 100; 

GUILayout.BeginArea (Rect (ScreenX, ScreenY, areaWidth, areaHeight));

    if(GUILayout.Button ("MoveCube")){




The script creates the button fine, but I get an error message that reads: "There is no 'Animation' attached to the "GUI" game object, but a script is trying to access it." after adding:


So, i am evidently only calling the animation, not the object with the animation attached to it, but not sure how to make that link happen. Thanks!

Hm? It's just:

function OnGui(){

If that's not what you want, please show us your script and explain what exactly isn't working, otherwise we can only guess what you are doing wrong.