I’m not too sure what your environment looks like since this is just code but I can make some assumptions based off of the way your code is structured and it looks like you have multiple LocalScripts, one per button to control visibility.
A better method you can rely on is to delete all those LocalScripts and instead make one LocalScript that’s in the location where the buttons are. When an option is clicked you can track which option was selected and then make its relevant frame visible. When a different option is clicked, first you make the last selected option invisible (if one is set) and then make the new one show.
A picture of your Gui’s hierarchy would help out in determining how this can be improved directly.
One way to clean it up is make an array of the items and use a single function to change visibility. Also agree with the other post to make a single local script not many.
local frames = {
script.parent:WaitForChild("Screen"),
script.parent:WaitForChild("options"),
...
}
function makeVisible(frameName)
for _, frame in ipairs(frames) do
frame.Visible = (frame.Name == frameName)
end
end
script.Parent.options.someButton.MouseButton1Click:Connect(function()
makeVisible("options")
end
One way to clean it up is make an array of the items and use a single function to change visibility. Also agree with the other post to make a single local script not many.
Where can I insert something of my own into the script