Make Part follow Mouses Position on local axes of another Part

Hi everyone.

I am struggling with a problem of finding out how I can make a part follow the mouse on 2 local axes of a secondary part. The secondary part is supposed to show the local axes of the whole thing.

So I want to be able to make a part follow the mouse in an area like this:

But if the secondary part has a diffrent rotation, then the area where the part can follow the mouse would look like this:

That plane has some axis n
If your mouse draws a ray through it, and that’s the position you want, then you need n:Dot(camPos + mouseDirection * dist) to be zero for some dist, which means on the plane. However, if you convert to the secondary part’s local space then this is along a specific axis and you just need to make that zero. If the plane is the Y axis of the part:

localPoint = secondary.CFrame:PointToObjectSpace(camPos)
localDir = secondary.CFrame:VectorToObjectSpace(mouseDirection)

Find the distance that makes the Y axis zero:

dist = -localPoint.Y / localDir.Y --May be Nan or infinity

Calculate the position of the intersection in world space:

worldIntersection = camPos + dist * mouseDirection

To be honest I dont quite understand some things. Like, what is worldIntersection supposed to mean or mousedirection?

world intersection is where the line formed by the mouse and the camera intersects the plane you drew. mouse direction is the direction of that ray. both are in world space.