Hello again! So, this Localscript is inside of a textbutton. When clicked, it is supposed to close startscreen (a frame) and open Step1 (another frame) Can you guys help me with why it won't work? I cannot use the output, because when I click 'Run' or 'Play Solo' my studio crashes :/
local startscreen = game.Players.LocalPlayer.PlayerGui.ScreenGui.startscreen local step = game.Players.LocalPlayer.PlayerGui.ScreenGui.Step1 script.Parent.MouseButton1Click:connect(function() startscreen.Visible = false step.Visible = true end)
This may or may not work depending on if your hierarchies are correct. If studio is crashing, it may be a bug with your computer. The local
keyword is not necessary with variables that are not within a specific scope. Also, I recommend using wait(1)
at the beginning of all localscripts so that you can guarantee that the character's assets are loading before you try modifying them.
wait(1) player = game.Players.LocalPlayer gui = player.PlayerGui.ScreenGui startscreen = gui.startscreen step = gui.Step1 script.Parent.MouseButton1Down:connect(function() startscreen.Visible = false step.Visible = true end)
One thing. Where are you putting the script? With the gui, or in the workspace, or other place?
ok so I got the info, and I am ready to start.
wait(1) -- has to load... then! local startscreen = game.Players.LocalPlayer.PlayerGui.ScreenGui.startscreen local step = game.Players.LocalPlayer.PlayerGui.ScreenGui.Step1 script.Parent.MouseButton1Click:connect(function() --THE MISTAKES! -- startscreen.Visible = false --should be startscreen.BackgroundTransparency = 1 --MORE MISTAKES! --step.Visible = true --should be step.BackgroundTransparency = 1 --Done end)
You set your GUI hierarchy incorrectly. LocalPlayer would not be inside StarterGui.