So I'm trying to close a GUI than a few seconds or minutes later the other one pops up on the screen but I seem to not be able to do it can you please fix my script I'm kinda new at scripting.
[Script]
01 | script.Parent.MouseButton 1 Click:Connect( function () |
02 | if script.Parent.Parent.FirstFrame.Visible = = true then |
03 | wait( 5.0 ) |
04 | script.Parent.Parent.FirstFrame.Visible = false |
05 | if script.Parent.Parent.FirstFrame.Visible = = false then |
06 | script.Parent.Parent.SecondFrame.Visible = true |
07 | wait( 5.0 ) |
08 | script.Parent.Parent.SecondFrame.Visible = false |
09 | end |
10 | end |
end)
Untested, but probably will work.
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | if script.Parent.Parent.FirstFrame.Visible = = true then |
3 | wait( 5 ) |
4 | script.Parent.Parent.FirstFrame.Visible = false |
5 | script.Parent.Parent.SecondFrame.Visible = true |
6 | wait( 5 ) |
7 | script.Parent.Parent.SecondFrame.Visible = false |
8 | end |
9 | end |
OR
01 | script.Parent.MouseButton 1 Click:Connect( function () |
02 | if script.Parent.Parent.FirstFrame.Visible = = true then |
03 | wait( 5 ) |
04 | script.Parent.Parent.FirstFrame.Visible = false |
05 | if script.Parent.Parent.FirstFrame.Visible = = false then |
06 | script.Parent.Parent.SecondFrame.Visible = true |
07 | wait( 5 ) |
08 | script.Parent.Parent.SecondFrame.Visible = false |
09 | end |
10 | end |
11 | ---you don't put decimals in your wait() |
You need to use PlayerGui
in order to access said goal.
Which means the script must be a LocalScript
in StarterPlayerScripts
01 | local player = game.Players.LocalPlayer |
02 | local FirstFrame = player.PlayerGui:WaitForChild( "ScreenGui" ):WaitForChild( "FirstFrame" ) -- Im assuming this is how it would go |
03 |
04 | local SecondFrame = player.PlayerGui:WaitForChild( "ScreenGui" ):WaitForChild( "SecondFrame" ) -- Im assuming this is how it would go |
05 | local bool = true |
06 | if FirstFrame.Visible = = true then |
07 | bool = true |
08 | end |
09 |
10 | script.Parent.MouseButton 1 Click:Connect( function () |
11 | if bool then |
12 | wait( 5 ) |
13 | script.Parent.Parent.FirstFrame.Visible = false |
14 |
15 | if not bool then |
this what I put in
local player = game.Players.LocalPlayer local FirstFrame = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("FirstFrame") -- Im assuming this is how it would go local SecondFrame = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("SecondFrame") -- Im assuming this is how it would go local bool = true if FirstFrame.Visible == true then bool = true end script.Parent.MouseButton1Click:Connect(function() if bool then wait(5) script.Parent.Parent.FirstFrame.Visible = false if not bool then script.Parent.Parent.SecondFrame.Visible = true wait(5) script.Parent.Parent.SecondFrame.Visible = false
1 | end |
end end)