Want velocity along a direction

How do I get the velocity of my ridgidbody along a certain direction?
So I can apply force in that direction if the velocity in that direction isn’t greater than max speed.

Usually Vector3.Project is what you want here. It returns only the part of the velocity along your given direction. However in your case it’s probably simply to just use the dot product. The dot product of your velocity with your normalized direction vector will be the signed speed component along your direction. It is actually used by Vector3.Project to calculate the length of the resuting projected vector.

    float velocityInDirection = Vector3.Dot(rigidbody.velocity, direction);

Think I solved it.

Vector3 direction;
float directionSpeed;
 
// you have to reverse the x axis for some reason
Vector3 temp = new Vector3(-rigidbody.velocity.x, rigidbody.velocity.y, rigidbody.velocity.z);
Vector3 rotatedVelocity = Quaternion.LookRotation(direction) * temp;
directionSpeed = rotatedVelocity.z;

You can use Vector3.Project():

if (Vector3.Project(rigidbody.velocity, direction).magnitude < maxSpeed) {
     rigidbody.AddForce(direction * someForce);
}