local function m()for m,M in pairs(Main)do M.Visible=false end end local function M(M)local C=M.Visible m()if C==true then return end if M.Visible==true then M.Visible=false elseif M.Visible==false then M.Visible=true end end for m,C in pairs(SettingsOpener:GetDescendants())do if C:IsA("\071\117\105\066\117\116\116\111\110")then local m=C:FindFirstAncestorWhichIsA("\070\111\108\100\101\114")C.Activated:Connect(function()M(Main[m])end)end end for m,C in pairs(ShopOpener:GetDescendants())do if C:IsA("\071\117\105\066\117\116\116\111\110")then local m=C:FindFirstAncestorWhichIsA("\070\111\108\100\101\114")C.Activated:Connect(function()M(Main[m])end)end end ToggleButton.Activated:Connect(function()M(ToggleButton)for m,M in pairs(Main)do if type(m)=="\117\115\101\114\100\097\116\097"then for m,M in pairs(m:GetDescendants())do if M:IsA("\071\117\105\066\117\116\116\111\110")then local m=M.Visible if m==true then M.Visible=false elseif m==false then M.Visible=true end end end end end local C=ToggleButton.Text if C=="\060"then ToggleButton.Text="\062"elseif C=="\062"then ToggleButton.Text="\060"end m()end)
--local function GetSameItem(instance)
--	for i,v in pairs(Main) do
--		if v==instance then
--			return v
--		end
--	end
--end

local function HideAllFrames()
	for i, v in pairs(Main) do
		v.Visible = false
	end
end

local function ToggleVisibility(Element)
	local vis = Element.Visible
	HideAllFrames()
	if vis == true then
		return
	end
	if Element.Visible == true then
		Element.Visible = false
	elseif Element.Visible == false then
		Element.Visible = true
	end
end

for i, v in pairs(SettingsOpener:GetDescendants()) do
	if v:IsA("GuiButton") then
		local folder = v:FindFirstAncestorWhichIsA("Folder")
		v.Activated:Connect(function()
			ToggleVisibility(Main[folder])
		end)
	end
end

for i, v in pairs(ShopOpener:GetDescendants()) do
	if v:IsA("GuiButton") then
		local folder = v:FindFirstAncestorWhichIsA("Folder")
		v.Activated:Connect(function()
			ToggleVisibility(Main[folder])
		end)
	end
end

ToggleButton.Activated:Connect(function()
	ToggleVisibility(ToggleButton)
	for i, v in pairs(Main) do
		if type(i) == "userdata" then
			for s, a in pairs(i:GetDescendants()) do
				if a:IsA("GuiButton") then
					local vis = a.Visible
					if vis == true then
						a.Visible = false
					elseif vis == false then
						a.Visible = true
					end
				end
			end
		end
	end
	local caret = ToggleButton.Text
	if caret == "<" then
		ToggleButton.Text = ">"
	elseif caret == ">" then
		ToggleButton.Text = "<"
	end
	HideAllFrames()
end)
