Collapse Sidebar




The origin Mouse property is a DataType/CFrame indicating where the mouse originated from. It is positioned at the Workspace/CurrentCamera and oriented toward the Mouse's 3D position.

Mouse/UnitRay starts at the same position as Origin, and extends for a stud in the same direction.

local unitRay = mouse.UnitRay
local origin = mouse.Origin
– unitRay.Direction = origin.p
– unitRay.Direction ≈ origin.lookVector

For the position of the Mouse in 3D space, see Mouse/Hit.

Code Samples

Mouse Origin vs Mouse Hit vs CurrentCamera Position

The code below visualizes the difference between Mouse/Hit and Mouse/Origin. In order to do this, the code uses the DataType/Vector3 positions of the hit and origin DataType/CFrame values using .p.

The difference is that the origin is “where the mouse came from” (its origin) and the hit is the position where the mouse hits (is when the player presses their mouse).

This example also visualizes that the mouse origin is very similar to the position of the CurrentCamera by printing the magnitude (distance) between the two positions.