How do I make a Inactive GUI?

Hello Fellow Developers, I would like to create a GUI that will become invisible after not being interacted with for a certain amount of time (15s). I’m not sure in the way that I would want to do this. Does anyone have any suggestions or examples regarding this topic?

1 Like

What do you mean interacted?

If you mean like if a button(s) don’t not get pressed, then you make a timer and it will reset every time the button(s) are pressed.

If you mean like any movement, then you can use MouseMoved. Any time the MouseMoved is fired, then it will reset the timer.

I hope this helped.

1 Like

Not Specifically Movement but I want to sort of create a timeout and if The Object is hit again then it will cancel the first timer then restart it basically. And if that timer ever hits 0 the GUI connected to it will disappear

1 Like

So, you can make a button and then the button is pressed/hit, it can reset the timer? Is that right?

1 Like

It’s not on a GUI. It’s not a button but yes I want it to restart a timer that’s already going. And if that timer hits 0 it will make the GUI disappear. I have a system that is Tool related, Whenever you hit the Object it will make it’s health go down and it opens the Health GUI for that Object. But I want a Automatic Disappearing GUI for it when the Object isn’t interacted with in 15s again while the Health GUI is already open. And yes that technically is correct, kinda.

1 Like

So like the health bar will show when it takes damage? Then if its like a npc, then you would use the Humanoid and do .Changed and every time that runs, check if the health has went down, if It has, Resart the timer. If there is no timer runner, and the Health bar is not up, then put up the Health bar and start a new timer.

If it has a health stored somewhere else, then do the same thing with the Humanoid, but with the value (do .Changed and check the .Value of it to change)

And If the health is stored in a script, you do the same thing but instead of doing .changed, you just keep checking if the health has changed.

I hope this helped. :slight_smile:

1 Like

I don’t know how to make a timer, and I already have a health check system without humanoid. Because it’s not npc :frowning:

That’s why I asked for examples :slight_smile:

what is the object you are talking about? a part? I know exactly how to do it

Check the last time the user interacted using tick() or os.clock(), then determine the last time it interacted and close the GUI after the specified amount of time had passed.

local finishChecking = false
repeat
    if tick()-lastInteracted > 15 then
        screenGui.Enabled = false
        finishChecking = true
        break
   else
        wait(1)
    end
until
    finishChecking
1 Like