I started using UserInputService and I found that I would have to cast my own mouse ray to get the typical Mouse.Target/Mouse.Hit properties I'm accustomed to.
I found ScreenPointToRay which looked like it would do what I needed, but I've encountered an issue
--input is an InputObject, camera is CurrentCamera local ignore = {} local mouseRay = camera:ScreenPointToRay(input.Position.X, input.Position.Y, 999) local target, hit = workspace:FindPartOnRayWithIgnoreList(mouseRay, ignore)
I've found that FindPartOnRay is ignoring all parts leaving target
nil and hit
's position is at the end of the ray. Am I doing this wrong here or could there be a bug on Roblox's end? I'm open to alternatives as long as it doesn't use the mouse.
Edit: I've found the depth property of ScreenPointToRay to be an offset for the Ray.Origin and the Ray length is 1 stud...
You're on the right track for solving your own problem. All you have to do is create a new ray with the proper length:
ray = Ray.new(ray.Origin, ray.Direction * 999))
ScreenPointToRay clearly returns a unit Ray, whereas FindPartOnRayWithIgnoreList expects the ray to have substantial length.