how do i make rigidbody. velocity follow the objects local rotation?

I’m making a movement script with velocity so I can use physics for other movement things.

I was wondering if there was a way to make the vector 3 follow the local rotation of the player

current code:
inputVector = new Vector3(Input.GetAxisRaw("Horizontal") * movSpeed, playerBody.velocity.y, Input.GetAxisRaw("Vertical") * movSpeed); playerBody.velocity = inputVector;

Something like that:

inputVector = playerBody.transform.InverseTransformDirection(playerBody.velocity);
inputVector.x = Input.GetAxisRaw("Horizontal") * movSpeed;
inputVector.z = Input.GetAxisRaw("Vertical") * movSpeed;
playerBody.velocity = playerBody.transform.TransformDirection(inputVector);