How to add max speed to 3D rigidbody?

I’m making a racing game but with flying cars (no gravity). Trying to add a maximum speed. Tried everything I found online and no solution. Below is what I’m working with, no solution attempted.

 Rigidbody rb;

 public float AccelSpeed = 100f;
 public float ReverseSpeed = 50f;
 public float RollSpeed = 50f;
 public float PitchSpeed = 50f;
 public float YawSpeed = 50f;

 private Vector3 LocalVelocity;

 public float MaxSpeed = 5f;

 private PlayerInput playerInput;
 private PlayerInputActions playerInputActions;

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

     playerInput = GetComponent<PlayerInput>();

     playerInputActions = new PlayerInputActions();

 private void FixedUpdate()

 void Accelerate()
     //Forward and backward input
     float ForwardInput = playerInputActions.Player.Accel_Decel.ReadValue<float>();
     ForwardInput *= Time.deltaTime; //converts to per second rather than per frame

     //Velocity Update
     Vector3 Acceleration = ((ForwardInput * AccelSpeed) * 1) * transform.forward;

     //Remove X velocity
     LocalVelocity = transform.InverseTransformDirection(rb.velocity);
     LocalVelocity.x = 0;
     rb.velocity = transform.TransformDirection(LocalVelocity);

 void Yaw()
     //Yaw input
     float YawInput = playerInputActions.Player.Yaw.ReadValue<float>();
     YawInput *= Time.deltaTime; //converts to per second rather than per frame
     Vector3 Yaw = (YawInput * YawSpeed) * transform.up;

 void Pitch()
     //Pitch input
     float PitchInput = playerInputActions.Player.Pitch.ReadValue<float>();
     PitchInput *= Time.deltaTime; //converts to per second rather than per frame
     Vector3 Pitch = (PitchInput * PitchSpeed) * transform.right;

 void Roll()
     //Roll input
     float RollInput = playerInputActions.Player.Roll.ReadValue<float>();
     RollInput *= Time.deltaTime; //converts to per second rather than per frame
     Vector3 Roll = (RollInput * -RollSpeed) * transform.forward;


Are you talking about max velocity in the Z direction or maximum of Z and Y? If both, you can use Vector3.ClampMagnitude after line 46, before you revert to world space for your rb.velocity.