✓ Accepted answer
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
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
local main = gui:WaitForChild("Main")
local general = gui:WaitForChild("General")
local buttons = gui:WaitForChild("Buttons")
buttons:WaitForChild("Main").Activated:Connect(function()
setTab(main)
end)
buttons:WaitForChild("General").Activated:Connect(function()
setTab(general)
end)
4 comments
I'd do it like that, yes
And now that you've programmed it, what's your question?
Yay you did it!
nebulous comments lol