Making an animation of 2 objects play

I have 1 animation and I have animated 2 objects, but I attach the animation to anything and the animation doesn’t play. How do I do this?

What I mean is, I have a walking animation of both my legs, but the animation doesn’t play when I attach it to any object.

i thinks you should add some scrpting code
use
animation.play();