local gui = script.Parent.Parent
local frame = script.Parent
local buttonsFrame = frame:WaitForChild("ButtonsFrame")
local sectionFrame = frame:WaitForChild("SectionFrame")
local cashFrame = sectionFrame:WaitForChild("CashFrame")
local cratesFrame = sectionFrame:WaitForChild("CratesFrame")
local loadoutFrame = sectionFrame:WaitForChild("LoadoutFrame")
local weaponsFrame = sectionFrame:WaitForChild("WeaponsFrame")
for _, v in pairs(buttonsFrame:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Down:connect(function()
if v.Name == "CloseButton" then
gui:Destroy()
else
-- I want this section to be shorter --
for _, i in pairs(sectionFrame:GetChildren()) do
if v.Name == "WeaponsButton" then
weaponsFrame.Visible = true
cratesFrame.Visible = false
cashFrame.Visible = false
loadoutFrame.Visible = false
elseif v.Name == "CratesButton" then
cratesFrame.Visible = true
weaponsFrame.Visible = false
cashFrame.Visible = false
loadoutFrame.Visible = false
elseif v.Name == "CashButton" then
cashFrame.Visible = true
cratesFrame.Visible = false
weaponsFrame.Visible = false
loadoutFrame.Visible = false
elseif v.Name == "LoadoutButton" then
loadoutFrame.Visible = true
cratesFrame.Visible = false
cashFrame.Visible = false
weaponsFrame.Visible = false
end
end
end
end)
end
end
Is there a way to make this shorter? I tried adding a for loop to go through the SectionFrame and :GetChildren() but I don't know how I could set the right frame to be visible. Any ideas?
