Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I go around making a change frame script?

I've tried doing this script but didn't work.

Local GUI = game.StarterGui.ScreenGui
Local Button = GUI.Button
Local Menu = GUI.Menu
Local Close = Menu.Close

Button.MouseButton1Down:connect(function()
       Button.Visible = false -- also tried Button.Visible = not Button.Visible and didn't solve it
       Menu.Visible = true
end)

If you're able to come up with a solution it'd be a great help, thanks.

1 comment

0

'local' should be lowercase, so 'Button' would be nil or would more likely error before assignment

1 answer

First thing, there's a lot of Silly errors in your script.

First, change 'Local' to 'local'.

Second, you must know that contents of StarterGui gets copied to PlayerGui, so using game.StarterGui.ScreenGui makes no sense.

What's the fix? Well, firstly the script should be a local script and should be in StarterGui.

I am assuming this is a local script and is inside the button. Here, this is how your script might look with changes:

local player = game.Players.LocalPlayer -- It will get your player and the contents inside it
local GUI = player:WaitForChld("PlayerGui").ScreenGui -- It will wait and search until it finds PlayerGui
local Button = GUI.Button
local Menu = GUI.Menu
local Close = Menu.Close

Button.MouseButton1Down:connect(function()
       Button.Visible = false 
	Menu.Visible = true
end)

Please Upvote and lemme know if it helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.