Skip to content

OnMouseLook

The mouse moved while the cursor is down - the moves the game turns the view with.

Once a frame at most, the frame’s sum of the mouse’s raw moves: dx > 0 to the right, dy > 0 towards you. It comes while the player looks around with the mouse (the cursor down; while it is up OnMouseMove tells the pointer’s place), also while a camera of the script’s or the game mode’s holds the view - a script’s own camera can follow the mouse. The game still turns the view with the moves unless the script holds the look (SetMouseLookCapture). Nothing comes while the emote wheel, the chat box or the F9 window has the mouse. A callback that raises an error is switched off.

function OnMouseLook(dx, dy)
-- ...
end
Parameter Type
dx number the moves to the right (negative to the left)
dy number the moves towards you (negative away from you)

nothing

local turned = 0
function OnMouseLook(dx, dy)
turned = turned + math.abs(dx)
if turned > 5000 then SendServerEvent("looked_around", "") turned = 0 end
end

SetMouseLookCapture · SetCamera · OnMouseMove · the The game’s UI for a script group of the index