How to get the velocity of an object

Hi, how do I get the velocity of an item? I tried this but it gives me an error.

stepCounter = mouseLookScript.GetComponent(MouseLookScript).transform.parent.position.velocity * gunBobSpeed;

Velocity is part of the Rigidbody component. If you don’t have a Rigidbody component and are instead moving the object yourself through the transform, then you will need to calculate the velocity by hand. If you do have a Rigidbody component, then you can do something like this in your script (C#):

Rigidbody rb = GetComponent<Rigidbody>();
Vector3 v3Velocity = rb.velocity; 

Velocity is a Vector3 giving back the velocity in the x, y, and z directions.

how to access a velocity in a particular axis? ,How to access a velocity in a particular Axis?