When using userinputservice I try to get the player’s mouse location in a 3D space yet the ray that gets casted seems to be lower than the player’s mouse by what seems around a stud
local camera = workspace.CurrentCamera
local mouse = uis:GetMouseLocation()
local ray = camera:ScreenPointToRay(mouse.X, mouse.Y, 1)
local ray = Ray.new(ray.Origin,ray.Direction * 999)
local part,pos = workspace:FindPartOnRayWithIgnoreList(ray,ignore)
That’s probably because GetMouseLocation does not account for GUI inset, to fix that you can try subtracting, (if i remember correctly) something like 36 pixels from the mouse position or use the GuiService:GetGuiInset() function.
So Something like:
local mouse = uis:GetMouseLocation() - Vector2.new(0,36)
or
local inset = GuiService:GetGuiInset()
local mouse = uis:GetMouseLocation() - inset
Strange. The developer docs indirectly say that ScreenPointToRay should be more accurate (see the reasoning in the image), but for you, it’s less accurate than ViewportPointToRay. When I tried it, neither of them had any offset.
It might have something to do with the third parameter of the PointToRay functions: