|| conditional statement not working

I can’t the script below to work. It is attached to a game object which also has the “inciseS” script attached to it.

animation["inciseS"].speed = 1.75;
var itoggle : boolean = false;

function Update (){

	if (Input.GetKeyDown(KeyCode.I))   
    itoggle = !itoggle;

	if(itoggle)
    animation.Play("inciseS");

    else if(!itoggle || Input.GetKeyDown(KeyCode.R))
    animation.Stop("inciseS");

}

The “R” key doesn’t work to stop the animation; only the toggle button “I” is working to stop the clip. I have the “R” key assigned to toggle a clip on a different game object - could this be why?

Inside your last condition, you need to set itoggle to false. Because what’s happening is that you’re pressing R, it’s stopping the animation, and then on the next frame it’s restarting it because itoggle is still true.