I remember sending you a demo with this code:
It helps to prevent getting stuck in corners.
Also, you should not use "Wait" inside "Player is dirChange" event. If you change the direction quickly several times, delayed "waits" from previous direction changes will mess the things up. Use Timer behavior - restart the Timer on every direction change.