aiming with animation

i want to have animation of aiming. i wrote my own script for it and its not working properly. every time i hold on the the right mouse button, the animation keep getting played over and over. is there a way to fix that?

here is the script.

var PlayAim = false;

function Update(){


gameObject.animation["Aim"].speed= 6;




gameObject.animation["Aim"].speed = -6;



make sure that your aiming animation is not set to loop