Vibrating character on collision with wall!

Hello readers, I have a character with a rigidbody and a script(below). It allows the player to move but when it collides with a wall while holding down the input, the character starts to vibrate and gets partially absorbed into the wall. The character will then be pushed in the opposite direction. Any idea what might be the cause?
Here is the code:

[Range(1, 100)]
public float MoveSpeed = 10f;
bool left;
bool right;

Rigidbody rb;

void Awake () {
	rb = GetComponent<Rigidbody> ();
}

// Update is called once per frame
void Update () {

	if (Input.GetAxis("player_move_joy") < 0 || Input.GetAxis("player_move") < 0) {
		left = true;
	}

	if (Input.GetAxis("player_move_joy") > 0 || Input.GetAxis("player_move") > 0) {
		right = true;
	}

}

void FixedUpdate(){

	if (left) 
	{
		rb.MovePosition(transform.position + Vector3.left * MoveSpeed * Time.deltaTime);
		left = false;
	}
	if (right) 
	{
		rb.MovePosition(transform.position + Vector3.right * MoveSpeed * Time.deltaTime);
		right = false;
	}
}	

}

That’s because the character doesn’t actually stop moving when it hits a wall; it just “teleports” him out when the game detects he’s in a wall. to prevent this, you could either use a raycast to test if the player is close to a wall and then disallow movement in that direction or simply set the Rigidbodies velocity, -1 being left, +1 being right:

                     if (left)
                    {
                        rb.velocity = new Vector2(-1, rb.velocity.y);
                        left = false;
                    }
                    if (right)
                    {
                        rb.velocity = new Vector2(1, rb.velocity.y);
                        right = false;
                    }