Make an animation play only once.

ok so i have a Javeascript here…

function Update() {
if(Input.GetMouseButtonDown(0))
animation.Play(“camera”);
}

camera is the name of the animation i have…i want the animation to only play once…as it is right now…i can press the button multiple times and it will replay the animation…i do not want that.

private var loop : boolean;

    function Update() {
    
    if((Input.GetMouseButtonDown(0)) && (!loop)){
        animation.Play("camera");
        loop = true;
    }
}

I’d check if the animation is playing before play the animation:

If(!animation.IsPlaying("camera"))
    animation.Play("camera");