How to cast ray using mouse.origin

local ray = workspace:Raycast(Vector3.new(mouse.Origin), Vector3.new(mouse.Origin * CFrame.new(0, 0, 1000)), RayParams)

Heres what I have rn.

I want to use Mouse.Origin because: Mouse.Hit.p Is wrong when shift lock - #3 by TOP_Crundee123

1 Like

I think you may be looking for the UnitRay property of the mouse, that’ll provide you a ray object that has positional and directional data.

local unitRay = mouse.UnitRay
local result = workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, raycastParams)

Alternatively, just by looking at the documentation, you can use the .Position and .LookVector properties of the Mouse.Origin, to get the origin and direction params respectively for the Raycast call. You’ll probably have to multiply the LookVector by the goal length tho.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.