PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Idle

Fired during every heartbeat that the mouse isn’t being passed to another mouse event.

Note, this event should not be used to determine when the mouse is still. As it fires every heartbeat it will fire between Mouse/Move events.

For information on how to obtain the Mouse object, please see the Mouse page.

Developers can find out the position of the mouse in world-space, and if it is pointing at any BasePart using the Mouse/Hit and Mouse/Target properties.

Note, developers are recommended to use UserInputService instead of the Mouse object in new work.


Code Samples


Mouse.Idle

This example demonstrates how mouse events are passed during each frame

local mouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService("RunService")
local events = {"Button1Down","Button1Up","Button2Down","Button2Up","Idle","Move","WheelBackward","WheelForward","KeyDown","KeyUp"}
local currentEvent
local frame = 0

for _,event in pairs(events) do
	mouse[event]:Connect(function ()
		currentEvent = event
	end)
end

local function processInput()
	frame = frame + 1
	print("Frame",frame,"- mouse event was passed to",currentEvent)
end

rs:BindToRenderStep("ProcessInput",Enum.RenderPriority.Input.Value,processInput)