Next Button Gui

Hello, I am trying to make a GUI button that acts as a next button that makes another GUI appear. Now, I have this script and I can’t get it to work for some reason.

Here’s my script:

local gui = game.ServerStorage.GameGUIs.LevelsFrame

script.Parent.MouseClick:Connect(function(player)

if player.PlayerGui:FindFirstChild(“GUI”) == nil then

gui:Clone().Parent = player.PlayerGui

end


I feel bad for asking… I’ve been working with GUI’s recently, and I can’t figure this one out. if you could identify my mistake, then that would be a great help! If not, thanks for reading. :slight_smile:

3 Likes

is this a local script or server script?

and you had some syntax errors, so i fixed below.

local gui = game.ServerStorage.GameGUIs.LevelsFrame
script.Parent.MouseClick:Connect(function(player)
    if player.PlayerGui:FindFirstChild(“GUI”) == nil then
        gui:Clone().Parent = player.PlayerGui
    end
end)
1 Like

It’s not a local script and it’s under the text button. Should I consider changing it to a Local Script? Thanks for your help!

1 Like

you have to use this event for GUIObject CLICKS and yes its recommended to use LocalScripts to handle local gui. (player.PlayerGui) and you wont be able to grab things from ServerStorage using a local script, so you’ll have to move that too.

local player = game.Players.LocalPlayer

textButton.MouseButton1Click:Connect(function()
    --code ehre
end)
1 Like

Just to clarify something, is LevelsFrame a GUI or just a frame?

gameguis is the screenGui and LevelsFrame is a frame.

Actually gameguis is the folder and LevelsFrame is the GUI. Sorry for the confusion.

just leave them in the StarterGui and disable them by default, enable them when the player clicks a certain button or does a certain thing, they shouldn’t be stored in ServerStorage if your going to start using a localscript with them.

1 Like

If LevelsFrame is a frame then moving it into the PlayerGui won’t do anything, you will need to move it into an actual GUI.

	gui:Clone().Parent = player.PlayerGui.GUI
1 Like

LocalScripts cannot access ServerStorage. If you are using a regular script, switch to a LocalScript and place the frame in ReplicatedStorage instead. I don’t really recommend any of this though.

When it comes to a next button, I will usually have all the required frames in only one Gui and the next button would just change the visibility of the next frame and hide the previous. I feel that needing to clone Guis in from elsewhere adds more processes that can be avoided entirely.

By the way there’s an object, UIPageLayout, that will handle frame pagination for you automatically.

1 Like