Is it possible to recreate Mouse.Hit and Mouse.Origin

I’m slowly attempting to move away from legacy features, but Mouse has a usecase that I cant seem to simulate otherwise.

Namely, the Mouse.Hit and Mouse.Origin CFrames that Mouse have. As far as I know, UserInputService does not have this functionallity.

So my question here is, how is it possible to recreate these two properties without using the Mouse class.

not sure if userinputservice has a solution, but the way I do it is,
cast a ray from a screen point

then just use the rayresults to get origin and hit and such (oh and to get mouse.hit, of course just put in the mouse x and y position into ScreenPointToRay() function)

What i’ve been thinking is using a method to convert UDim into vector, that way the mouse’s position on the screen can be converted to a 3d vector…
I found this: