Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a UserInputService equivalent to Mouse.Idle?

Asked by
Launderer 343 Moderation Voter
4 years ago

Is there a UserInputService equivalent to Mouse.Idle and if there is would you be kind enough to share with me.

1 answer

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 years ago

Unfortunately the users mouse in UserInputService is a constant event so it will not idle / have an end state.

Although you could use InputChanged to detect if the Mouse has been moved like so:

UIS = game:GetService('UserInputService')

mouseIdle = false

mouseIdleDelay = 10 -- in seconds

UIS.InputChanged:Connect(Input)
    if Input.UserInputType == Enum.UserInputType.MouseMovement then
        mouseIdle = false
    end
end)

spawn(function()
    while wait(mouseIdleDelay) do
        mouseIdle = true
    end
end)

If you have any other questions feel free to let me know.

0
Yes I am aware of MouseMovement and I know I could just create a variable and find out when the mouse isn't moving from that but I was just hoping there was a way to do it without that. Thank you for confirming what I already thought. Launderer 343 — 4y
Ad

Answer this question