How do I load one GUI at a time?

I want to be able to make three GUIs load one at a time, but the main problem for me is that when I try to do this none of them disable or disappear.

I have tried asking on a different platform, but no one helped me at all. I’ve tried youtube and searching this forum for answers to no avail.

local discla = game.StarterGui.Disclaimer.Disclaimer
local Main = game.StarterGui.MainMenu.MainMenu
local Note = game.StarterGui.NoteFromJoey.NoteFromJoey


Note.enabled = false
Main.Enabled = false
discla.Enabled = true

local button = game.StarterGui.Disclaimer.Disclaimer.TextButton

button.MouseButton1Click:Connect(function(plr)
	discla:Destroy()
	print("Uh")
end)


button.MouseButton1Click:Connect(function(plr)
	Main.Enabled = true
end)


local play = game.StarterGui.MainMenu.MainMenu.Menu.PlayBTN
local Quit = game.StarterGui.MainMenu.MainMenu.Menu.Quit


play.MouseButton1Click:Connect(function()
	Main:Destroy()
	Note.Enabled = true
end)

Quit.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer:kick("Quit Game")
end)

local old = game.StarterGui.NoteFromJoey.NoteFromJoey.Pages.OldPage

old.MouseButton1Click:Connect(function()
	Note:Destroy()
end)

I am very new to scripting, so I most likely did something wrong. I have no idea why they’re not disabling. I want someone to help me understand what I did wrong and how to fix it.

1 Like

Put all of your UI frames in one GUI object, then enable and disable them by using frame.Visible.

When a client runs the script, everything in StarterGui is cloned in PlayerGui and runs there. Which means you have to replace game.StarterGui with game.Players.PLAYERNAME.PlayerGui to get valid results.

I tried what you said, but I keep getting this error. "Players.ScarlettPhoenixx.PlayerGui.LocalScript:1: attempt to index nil with “Disclaimer” I probably did something wrong, per usual

local Discla = game.Players.Name.PlayerGui.Disclaimer

local Main = game.Players.Name.PlayerGui.MainMenu

local Note = game.Players.Name.PlayerGui.NoteFromJoey

Note.Enabled = false

Main.Enabled = false

Discla.Enabled = true

local button = game.Players.Name.PlayerGui.Disclaimer.Iagree

button.MouseButton1Click:Connect(function(plr)

Discla:Destroy()

end)

button.MouseButton1Click:Connect(function(plr)

Main.Enabled = true

end)

local play = game.Players.Name.PlayerGui.MainMenu.Menu.PlayBTN

local Quit = game.Players.Name.PlayerGui.MainMenu.Menu.Quit

play.MouseButton1Click:Connect(function()

Main:Destroy()

Note.Enabled = true

end)

Quit.MouseButton1Click:Connect(function()

game.Players.Name:kick("Quit Game")

end)

local old = game.Players.Name.PlayerGui.NoteFromJoey.Pages.OldPage

old.MouseButton1Click:Connect(function()

Note:Destroy()

end)

This is the script I used, I’m not very good with scripting which is why I’m trying to learn. Trial and error!

Replace game.Players.Name with game.Players.LocalPlayer. Also tried to clean your code a bit:

local Players = game:GetService("Players") 

local Player = Players.LocalPlayer 
local PlayerGui = Player:WaitForChild("PlayerGui", 5) 
if not PlayerGui then warn("PlayerGui wasn't found") return end 

local Disclaimer = PlayerGui:WaitForChild("Disclaimer")
local Main = PlayerGui:WaitForChild("MainMenu")
local Note = PlayerGui:WaitForChild("NoteFromJoey")

Note.Enabled = false
Main.Enabled = false
Disclaimer.Enabled = true

local button = Disclaimer.Iagree

button.MouseButton1Click:Connect(function()
	Disclaimer:Destroy()
end)
button.MouseButton1Click:Connect(function()
	Main.Enabled = true
end)

This is very helpful, however, it is now saying that the “Disclaimer” is not a valid member of the PlayerGui, is there supposed to be a waitforchild for the actual ScreenGui?

Yes. You need to get the ScreenGui first.