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

Can't load three GUIs one at a time?

Asked by 2 years ago

I am trying to disable two GUIs and only load one.. when a button is clicked the previously loaded GUI will disappear/disable and then one other GUI will appear, the same will happen to this one as well, a button clicked will disable that GUI and activate another, then that GUI will disappear and none will be there. The problem I'm having is none of the GUIs disappear whatsoever, they're all still there.

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 coding, so I most likely did something wrong, but of course, I do not know what. I have three folders, each of them has its own GUI in it.

0
You used :Destroy(). This removes the object from existence so you will not really be able to have it visible as it will actually destroy the object. Try something else like changing Enabled to true. Also you see that they are still in startergui because when a player joins it attaches those guis to playergui. So the startergui folder isn't affected at all by your code voidofdeathfire 148 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

In lines 1 to 3, you have var which is led to the gui in startergui but not the guis inside the player. When a player joins, everything in the startergui gets sent to the playergui folder which is inside the player. And :Destroy() destroys an object completely.

local discla = game.Players.LocalPlayer.PlayerGui.Disclaimer.Disclaimer -- Do game.Players.LocalPlayer.PlayerGui
local Main = game.Players.LocalPlayer.PlayerGui.Gui.MainMenu.MainMenu
local Note = game.Players.LocalPlayer.PlayerGui.NoteFromJoey.NoteFromJoey


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

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

button.MouseButton1Click:Connect(function(plr)
    discla.Enabled = false
    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.Enabled = false
    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.Enabled = false
end)
Ad

Answer this question