Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I Am Trying To Create A Settings GUI With Tabs. Does Anyone Know How To Do It?

Asked by 4 years ago
Edited 4 years ago

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)
0
I'd do it like that, yes User#17685 0 — 4y
0
And now that you've programmed it, what's your question? hiimgoodpack 2009 — 4y
0
Yay you did it! SethHeinzman 284 — 4y
0
nebulous comments lol User#23252 26 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
0
Thank you. Aiden_12114 79 — 4y
Ad

Answer this question