Leg is in different position when animation is played

Alright so I was animating a rig for a youtube video however when I run the game or play it, the leg is different compared to the animation editor. Here are some screenshots:
Error1
Error2
NoError1
NoError2

the first 2 photos are the ones that are glitched