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:
01 | local HelpButton = script.Parent.Button |
02 | local HelpFrame = script.Parent.Frame |
03 | local HelpOpened = false |
04 | ------------------------------------------------------------------- |
05 | HelpButton.MouseButton 1 Click: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 |
18 | end ) |
This should work:
01 | local HelpButton = script.Parent |
02 | local HelpFrame = script.Parent.Frame |
03 | ------------------------------------------------------------------- |
04 | HelpButton.MouseButton 1 Click: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 |
12 | end ) |
Make sure to put this in the HelpButton!