You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to get the buttons to open the frame
-
What is the issue? the 4 buttons in this screen shot are not opening when clicked
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub? i tried to debug my code
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Frame = game.StarterGui.SurfaceGui
local CurrentFrame = nil
for _, button in pairs(Frame:GetChildren()) do
print(button.Name)
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
local relatedFrame = nil
for _, frame in ipairs(Frame:GetChildren()) do
if frame:IsA("Frame") then
if frame.Name == button.Name then
relatedFrame = frame
end
end
end
if relatedFrame then
if relatedFrame == CurrentFrame then
CurrentFrame.Visible = false
CurrentFrame = nil
elseif CurrentFrame then
CurrentFrame.Visible = false
CurrentFrame = relatedFrame
CurrentFrame.Visible = true
else
CurrentFrame = relatedFrame
CurrentFrame.Visible = true
end
end
end)
end
end