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.
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)
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)
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.
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.