Player movment script help

I’ve made a player flying script, but i have a problem. When i stom flying forward the player keeps sliding like on ice. I’ve added some code to fix that bit it doesn’t work. Can someone please help me fix the slyding. By the way the sript works as it should while the “Use gravity” is on.
var cameraObject : GameObject;

var flying : boolean = false;

var maxFlySpeed : float;
var flyAcceleration : float;

var flyDeacceleration : float;
var upDownDeacceleration : float;

var flyDeaccelerationVolx : float;
var flyDeaccelerationVolz : float;

var horizontalMovement : Vector2;

var upAcceleration : float;
var downAcceleration : float;

function Update () {

 horizontalMovement = Vector2(rigidbody.velocity.x, rigidbody.velocity.z); 
 	//Sets max flying speed
	if (horizontalMovement.magnitude > maxFlySpeed){
  		
 	horizontalMovement = horizontalMovement.normalized;
   	horizontalMovement *= maxFlySpeed;
 		
 	}
 		
 		if (Input.GetKeyDown("f")){
		
		flying = !flying;
		
		}
 		
 		
 		//Your not pressing any key's
 		if(Input.GetAxis("Horizontal") == 0 &&	Input.GetAxis("Vertical") == 0){
 		
 		//smoothly stop the player
 		rigidbody.velocity.x = Mathf.SmoothDamp(rigidbody.velocity.x, 0, flyDeaccelerationVolx, flyDeacceleration);
 		rigidbody.velocity.z = Mathf.SmoothDamp(rigidbody.velocity.z, 0, flyDeaccelerationVolz, flyDeacceleration);
 		
 		}		
 			
			rigidbody.velocity.x = horizontalMovement.x;
		    rigidbody.velocity.z = horizontalMovement.y;
 		
 			//Rigidbody.useGravity = true;
 		
 			//Fly's right, left, forward, back
 			rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * flyAcceleration * Time.deltaTime, 0, Input.GetAxis("Vertical")* flyAcceleration * Time.deltaTime);
 			//fly's up	
  			rigidbody.AddRelativeForce(0, Input.GetAxis("Up") * upAcceleration * Time.deltaTime, 0);
  			//fly's down
  			rigidbody.AddRelativeForce(0, Input.GetAxis("Down") * downAcceleration * Time.deltaTime, 0);
  			//rotates
   	    	transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(PlayerLookScript).currentYRotation, 0);

}

I’m guessing you want to return after smoothly stopping the player, or it will continue to the code below where maybe it’s making him go again.

I want the player to smoothly stop when the “use gravity” in the ridgidbody is off.