Unity say that object doesn't have a Animation

I made a Javascript that play a reloading animation when R is pressed, and put it in my weapon, that have the reloading animation. The problem is that when i press R in play mode, Unity say the following:

“MissingComponentException: There is no ‘Animation’ attached to the “SubmachineGun” game object, but a script is trying to access it.”

What i did wrong? The weapon have child objects like magazine,body etc… is this the problem? What i need to do? Pls help!

OBS: I wasn’t able to upload the print. It’s “too heavy”

You need to have an Animation Component attached to your gameobject to which you are trying to play the animation.

But instead of using the legacy animation component you can use Animator for the same.