Animation wont play, Help!

I’m having a problem with animations. Whenever I call them in a script and place the animation on the object that I want it to play, it gives me an error saying that the animation couldn’t be found! For example, I wanted to make a basic shoot animation so that when I fire, the gun gives recoil. I called it in a script, put the animation on my gun, fired, and it stops my game, then tells me a script is trying to access an animation that doesn’t exist! Thanks in advance!

This is caused because your code doesnt have the rght animation name or you did not use brckets , for example

animation.Play(myanimation);

Will not work because

  1. You did not use a variable for myanimation
  2. You did not use Speech marks

Example

animation.Play("myanimationname");

would only work if you have a animation named myaniamtionname

Also if this doesnt resolve , please put your code in your question