Still have questions? Join our Discord server and get real time help.
1

# How to I detect if something is 'inactive' ?

Asked by 4 years ago

So I'm trying to detect if the Surface GUI has been clicked in x amount of time (let's just say 5 seconds). If it is idle for x amount of seconds, then the GUI resets (I have that code done). I have no idea, I tried doing mouse.Idle() but that would be for the mouse, not the gui. Also the mouse is always idle when not moving, so that wouldn't work.

I mean, here is the code I tried, but its with mouse.Idle() that I know doesn't work

if mouse.Idle() then
Reset()
end


Any tips or events I can do to detect it? Thanks

I did look at the object browser but no luck

0
I think you can just have the idle normally, on press change, and wait(5) to use function reset() DrCylonide 146 — 4y
0
Alright. I'll just do that. I plan to make my game very basic anyway lol DeveloperSolo 355 — 4y

0
Answered by 4 years ago

Try this:

if mouse.Idle then
Reset()
end


But make sure that you actually have that in a function or something if you want it to work. Otherwise, you'll wanna do:

mouse.Idle:connect(function()
Reset()
end)


I suggest you use the one above to detect if the mouse is idle.

0
Thanks. It works for what I need. DeveloperSolo 355 — 4y
0
No problemo. iDev_Percy 45 — 4y