Include a standalone, bare-bones rbxl file with only the code you want reviewed.
- Code Review is for reviewing specific parts of your code, and not your whole game.
- Code Review is intended for improving already-working code. If you need help debugging your code, please use Scripting Support.
Provide an overview of:
- What does the code do and what are you not satisfied with? The code does not work as expected to
- What potential improvements have you considered? None
- How (specifically) do you want to improve the code? I want to improve the ability to get it to work
local Frame = script.Parent.ScrollingFrame
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
Hello i don’t know if i did this in the wrong order but heres my layout


as you can see when i click the buttons on the surface gui the frame does not open i don’t know if it’s my layout or what.