I have come up with this function, but sadly it seems to always be off by quite a bit, which makes it unusable for my cause.
function GetMouseCFrame()
local MousePos = UIS:GetMouseLocation()
local Magnitude1Ray = cam:ScreenPointToRay(MousePos.X,MousePos.Y)--original ray can only be 1 stud long
local NewRay = Ray.new(Magnitude1Ray.Origin,Magnitude1Ray.Direction* 1000)--replicated ray to get greater length
local Target, Position = workspace:FindPartOnRay(NewRay, plr.Character)
return Target
end
print(GetMouseCFrame().Name)
Thanks in advance
The mouse is based on the client and has a position on the screen in 2d. This means that you can’t have a CFrame value with the mouse. The mouse’s 3D position can get raycasted using a bunch of math. But that only gives you where the mouse is pointing at. Please give us more information on what you are trying to achieve.