Hello, I want to detect when the mouse is not being moved. Now I have tried mouse.Idle and mouse.Moved but neither of these are doing what I want. e.g when I have this code;
mouse.Idle:Connect(function()
print("1")
end)
It will print every frame regardless of me touching my mouse why is this?
local mouse = game.Players.LocalPlayer:GetMouse()
local events = {"Button1Down","Button1Up","Button2Down","Button2Up","Idle","Move","WheelBackward","WheelForward","KeyDown","KeyUp"}
local currentEvent
for _,event in pairs(events) do
mouse[event]:Connect(function ()
currentEvent = event
end)
end
Now you can check if the player mouse is idle using:
if currentEvent == "Idle" then
print(the player mouse is Idle)
end
Umm, why was this classified as the solution? I copied it out and it doesn’t work, cus even logically the mouse has to be in the same very position since the spawn of the character and so it would never reference if it was standing still relative to the run time of the game
local mouse = game.Players.LocalPlayer:GetMouse()
local lastpos = 0
mouse.Idle:Connect(function()
if mouse.Hit == lastpos then
print("Mouse isn't moving")
end
lastpos = mouse.Hit
end)