Movement messed up because of rotation. How to solve

So, i have a FPS template, keeping the default movement things, just adding a few variables. When I look up or down/ anything other than the horizon, the player starts glitching while walking. BUT if I look fully up or down and try to walk forward, it launches me backwards at Mach 7. pls help me solve this bullsh*t

Does anyone know why this happens??

Proof that I haven’t destroyed the code:

Does it work ok with the mouse and not the gamepad?