You will encounter at least 100 other problems with this or with any other movement code/ basis this short. Movement codes are not simply using a single or two provided engine functions but oftentimes consist of tens of thousands lines of code.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends