Can't get around mouse.UnitRay

Title is self explainatory, I’m having trouble understanding what mouse.UnitRay is. I’ve went around the forum and there was this 1 question. I looked it up and still, no understanding at all. If anyone would explain me in a simple way I can comprehend, that would be appreciated. Thanks in advance!

The UnitRay property is a Ray directed toward the Mouse 's position in 3D space (described by Mouse.Hit ). It originates from the 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

source: Mouse | Documentation - Roblox Creator Hub

1 Like

Is the origin always the CFrame of workspace.CurrentCamera and what’s the length of the ray?

Yes and 1.

2 Likes