Control rotation rotates all bones, but works fine in preview?

In simple terms, this is what I am trying to achieve:

This is what happens in game, when I look down (also goes for looking up):

277484-help1.png

And this is what it looks like in the preview:

As you can see the preview works fine, but in game it doesn’t.
Here is the code:

I have no idea what I’m doing wrong, someone please help me.
PS: The animation works just fine, I just want the legs to stay on the ground when looking up and down.