Braking/slowing down when moving the opposite the direction

im not sure how to make the player slow down when moving in the opposite direction instead of instantly changing the direction

example: Clip, Edit, and Share Your Game Clips & Gameplay - Medal