PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

UnitRay

Mouse

Ray

The UnitRay property is a DataType/Ray directed toward the Mouse’s position in 3D space (described by Mouse/Hit). It originates from the Camera/CFrame|CFrame of the Workspace/CurrentCamera. Like all unit rays, it has a distance of 1.

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
print(mouse.UnitRay.Direction.magnitude) -- Always 1