Whenever i try to rotate my player it snaps back to its normal position

Please use code tags in the future.

Anyways, the issue is that whenever you have 0 input, you’re setting the rotation to Quaternion.Euler(0, 0, 0):

float targetAngle = Mathf.Atan2(MoveDirection.x, MoveDirection.z)*Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, targetAngle, 0);