I got the closest point of a ray. How do I limit how far it can go?

I found the initial formula on another post on here but it was relatively old and solved, so I’m making a new one.

I am trying to make a system that plays a supersonic crack if a bullet passes by you, and have found a formula that lets me get the closest point to my camera on a ray. However, it goes past the start and end points of where the bullet would be, which should not happen. How do I limit how far this point can go?

Video below:

Thanks in advance.

Woops, forgot to include the formula.

local A, B = (Origin - Point), Direction.Unit
local V = A - A:Dot(B) * B.Unit
    
return Point + V

Origin is where the bullet starts. Point is the camera position. Direction is the ray direction.

Try clamping the magnitude of the projected vector