Animation Play On Click

Hey all. I’m trying to script a function in which an animation plays on click of a gameobject. However, instead of naming the animation in the parenthesis, I want to be able to declare it as a variable, so I can use the script for multiple gameobjects so I don’t have many scripts for different animations. However, I’m getting an error. Any help?

Error: Assets/Scripting/Click to move.js(7,17): BCE0004: Ambiguous reference ‘animation’: Click to move.animation, UnityEngine.Component.animation.

var animation : Animation;

function Update() {
	if(Input.GetMouseButtonDown(0))
	{
		animation = AnimationClip;
		animation.Play();
	}
}

actually, you have to remove the type “Animation” from your animation for it to work,
try this,

     var animation : String;
    function Update() {
    if(Input.GetMouseButtonDown(0))
    {
    animation.Play(animation);
    }
    }

this is because the syntax of animation.play is,

animation.play(String); //string will be the name of the animation to be played...