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]
script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.FirstFrame.Visible == true then wait(5.0) script.Parent.Parent.FirstFrame.Visible = false if script.Parent.Parent.FirstFrame.Visible == false then script.Parent.Parent.SecondFrame.Visible = true wait(5.0) script.Parent.Parent.SecondFrame.Visible = false end end
end)
Untested, but probably will work.
script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.FirstFrame.Visible == true then wait(5) script.Parent.Parent.FirstFrame.Visible = false script.Parent.Parent.SecondFrame.Visible = true wait(5) script.Parent.Parent.SecondFrame.Visible = false end end
OR
script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.FirstFrame.Visible == true then wait(5) script.Parent.Parent.FirstFrame.Visible = false if script.Parent.Parent.FirstFrame.Visible == false then script.Parent.Parent.SecondFrame.Visible = true wait(5) script.Parent.Parent.SecondFrame.Visible = false end end ---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
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 end end end)
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
end
end end)