how can I make my ray point towards the mouse position and not the cameras lookvector?
im looking for a substitute for mouse.hit but this does not make a ray pointing to the mouse position like the wiki said it would, please help
01 | local uIS = game:GetService( "UserInputService" ) |
02 | local mouse = uIS:GetMouseLocation() |
03 | local camera = workspace.CurrentCamera |
04 | uIS.InputBegan:Connect( function (input, processed) |
05 | if processed then return end |
06 | if input.UserInputType = = Enum.UserInputType.MouseButton 1 then |
07 | local unitRay = camera:ViewportPointToRay(mouse.X, mouse.Y, 0 ) |
08 | local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * 100 ) |
11 | print (ray.Instance.Name) |