Player Movement continues when switching player.

Hi,
I have a game where the player will switch between characters when pressing shift.

Normally the players move the following

float x = Input.GetAxisRaw("Horizontal");
float moveBy = x * speed;
rb2d.velocity = new Vector2(moveBy, rb2d.velocity.y);

However, when switching character, if they switch while the current character was moving. The movement force will still be applied, meaning that character will continue moving in that direction.
The Switching is done, by enabling and disabling the movement scripts on the characters.

Is there a way to fix this, so they wont continue to move forever, but eventually come to a stop?

Well, you can make something like that:

private void OnDisable()
{
    var velocity = rb2d.velocity;
    velocity.x = 0;
    rb2d.velocity = velocity;
}