Walking animation?

Ok i could never figure this out so I need some help x.X

How do I make a walking animation where when you click on the left arrow, your account walks left with the walking animation, and the LEGS move smoothly back and forth.

Same for right arrow and such.

If its possible does anyone have a source script for it or anything x.X?