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

How do I make a GUI close after a set time?

Asked by 11 years ago

Ok so I've made a help script that automatically closes 10 seconds after you open it, and it works fine. But the problem I've been having is that if I closed it manually and then opened it manually while the script was waiting 10 seconds to close the gui, the time doesn't reset, so it closes when it would've closed if the player didn't interrupt the timer. What I'm trying to do is have the time reset whenever the GUI is opened. This is basically what the code looks like:

01local HelpButton= script.Parent.Button
02local HelpFrame = script.Parent.Frame
03local HelpOpened = false
04-------------------------------------------------------------------
05HelpButton.MouseButton1Click:connect(function()
06    if HelpOpened then
07        HelpOpened = false
08        HelpFrame.Visible = false
09    else
10        HelpOpened = true
11        HelpFrame.Visible = true
12        wait(10)
13        if HelpOpened then
14            HelpOpened = false
15            HelpFrame.Visible = false
16        end
17    end
18end)

1 answer

Log in to vote
0
Answered by 11 years ago

This should work:

01local HelpButton= script.Parent
02local HelpFrame = script.Parent.Frame
03-------------------------------------------------------------------
04HelpButton.MouseButton1Click:connect(function()
05    if HelpFrame.Visible then
06        HelpFrame.Visible = false
07    else
08        HelpFrame.Visible = true
09        wait(10)
10        HelpFrame.Visible = false
11    end
12end)

Make sure to put this in the HelpButton!

0
But that doesn't reset the timer though TurboFusion 1821 — 11y
Ad

Answer this question