So I made a clear baseplate, put two screen guis, add frames to both of em, add a button to the first one that makes its current GUI set the Enabled option to false and the other to true (Having it set to false by default). It doesn’t work. Anything that I’m missing here…?
It’s sort of more complicated how StarterGui works, StarterGui is just a container for all the guis that everyone gets a copy of when they join, you’ll have to make changes to your copy of those guis, and not the container with the originals. You have a folder directly parented to your player called PlayerGui, where your copy of the guis are kept, you’re supposed to make those changes there.
local PlayerGui = game.Players.LocalPlayer.PlayerGui
local nextGui = PlayerGui.NextScreenGui --**your** version of nextGui
Had no idea about this. Thanks! All I have to do is, from the PlayerGui, grab the ScreenGui and set the Enabled value to false and then, from the PlayerGui, set the NextScreenGui Enabled value to true, right?
Here is the reason why it won’t work as jefelocaso explained earlier.
Here is my solution I think. (The localscript would be in startercharacterscripts)
local player = game.Players.LocalPlayer
local nextGui = player.PlayerGui.NextScreenGui
local thisGui = player.PlayerGui.ScreenGui
local button = thisGui.Frame.TextButton
button.MouseButton1Click:Connect(function()
thisGui.Enabled = false
nextGui.Enabled = true
end)
It worked! But why? Since StarterCharacterScripts is often used for the player’s character often known as the player’s model? It would have made more sense in the StarterPlayerScripts but it didn’t worked there
The issue here may be that the GUI hasn’t loaded at the point when you are accessing gui2. Using WaitForChild() should account for this issue.
local player = game.Players.LocalPlayer
local nextGui = player.PlayerGui:WaitForChild("NextScreenGui")
local thisGui = player.PlayerGui:WaitForChild("ScreenGui")
local button = thisGui.Frame.TextButton
button.MouseButton1Click:Connect(function()
thisGui.Enabled = false
nextGui.Enabled = true
end)
Also, as a side note, if you make gui1 (thisGui) a parent of the LocalScript, then you can access the GUI by simply using script.Parent rather than going through the contents of PlayerGui.