I am attempting to use Ray Casting for the first time and I feel like i'm missing something simple. Attached is my current code. At the moment the part returned is nil and the position does not seem to be correct. If anyone could give me a link or pointer that would be great! Thanks.
player = game.Players.LocalPlayer
mouse = player:GetMouse()
function camTurn()
local camRay = mouse.UnitRay
basePart, location = workspace:FindPartOnRay (camRay)
print (basePart .. " Is touched here: "..location)
end
RunService:BindToRenderStep("CamTurn",500,camTurn)--I have tried lower priority as well

1 comment
Are you trying to find the position of a part that the mouse is hovering over or?