Does anyone know how to create a settings gui with a list of the options buttons? When you press one like "General" for example it will show all options in the General cat.
This is the code I currently have in the text button:
local current = script.Parent.Parent.CurrentFrame.Value script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Parent[current].Visible = false script.Parent.Parent.Parent.General.Visible = true end)
You have the right idea, but there are a few improvements you can make. Notice how you have script.Parent
in a number of places, and script.Parent.Parent.Parent
in a few more? If you label each object with a different variable, it can make your script easier to read and change.
Also, you have a bug - line 1 should not have .Value
at the end (and so you will need current.Value
instead of just current
on line 4). Values are copied, so when CurrentFrame.Value
later changes, current
will not update with it. (Also, you need to update the current
variable.)
It looks like you're designing this system to have multiple scripts (one per button). In my opinion, it is easier to organize if you have only one script that handles an entire GUI.
The following script is an example of an all-in-one script - you'll need to adapt it to your situation if you want it to work.
local current -- refers to the current tab (using just a local variable instead of an ObjectValue) local function setTab(tab) if current then current.Visible = false end current = tab if current then current.Visible = true end end local gui = script.Parent -- Maybe these are some frames/tabs local main = gui:WaitForChild("Main") local general = gui:WaitForChild("General") -- Maybe you have a Buttons object containing the buttons to switch between tabs local buttons = gui:WaitForChild("Buttons") buttons:WaitForChild("Main").Activated:Connect(function() -- "Activated" is preferred over MouseButton1Click setTab(main) end) buttons:WaitForChild("General").Activated:Connect(function() setTab(general) end)