What you want to do here is 'link' different objects. In this case, a Frame and a TextButton.
This is the explorer view of what it should look like in the above situation.
- ScreenGui
- LocalScript (that handles the wiki)
- WikiFrames
- Hoole (frame with Visible set to false)
- WikiButtons
What you want to do is iterate through a table of all of the buttons. Then, when the button gets clicked, it searches for a corresponding frame to the button that got clicked. It then toggles the frame from there.
The following code should be inside the LocalScript shown above:
local g = script.Parent
local frames = g:WaitForChild("WikiFrames")
local buttons = g:WaitForChild("WikiButtons")
local currentFrame
for _,v in pairs (buttons:GetChildren()) do
v.MouseButton1Down:connect(function()
local f = frames:FindFirstChild(v.Name)
if f then
if f == currentFrame then
f.Visible = false
else
if currentFrame then
currentFrame.Visible = false
end
currentFrame = f
currentFrame.Visible = true
end
end
end
end
If you need more, I am happy to help. You may need help converting this script to work completely with your GUI.
EDIT:
Alternately, you could make a large dictionary with individual values, and have only one frame with some TextLabels inside it that get changed when one of the values-inside-the-dictionary's corresponding button is clicked.
This solution may be more efficient, and faster/easier to create.
Hope I helped!
~TDP
2 comments
Look into using the MouseButton1Down event, and the 'Visibility' property for frames. It's difficult to answer this question due to how elaborate your gui is.
I've thought about using that, but how would I close an already open page when another button is pressed?