local function u(u,R,X,S,V)local Q if V then Q=0 else Q=.3 end local A=TweenInfo.new(Q,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)local i=subPageOrders[u.Name]local F if tonumber(R)then F=u[i[R]]end local v=u[i[X]]local f if F and F:IsA("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")then F.ScrollBarImageTransparency=1 end if v:IsA("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")then v.ScrollBarImageTransparency=0 end local C=u:FindFirstChild("\083\101\097\114\099\104\066\097\114")if C then if v.Size.Y.Scale<.85 then C.Visible=true else C.Visible=false end end for R,X in pairs(i)do local S=u[X]if S~=v and S~=F then S.Position=UDim2.new(-2,0,S.Position.Y.Scale,0)end end if S=="\082\105\103\104\116"then f=1 elseif S=="\076\101\102\116"then f=-1 end local Z=f*-1 u.NavigateButtons.TextLabel.Text=string.upper(v.Name)v.Position=UDim2.new(f,0,v.Position.Y.Scale,v.Position.Y.Offset)local q=main.tweenService:Create(v,A,{Position=UDim2.new(0,0,v.Position.Y.Scale,0)})q:Play()if F then local u=main.tweenService:Create(F,A,{Position=UDim2.new(Z,0,F.Position.Y.Scale,0)})u:Play()spawn(function()u.Completed:Wait()if F.Position.X.Scale==Z then F.Position=UDim2.new(-2,0,F.Position.Y.Scale,0)end end)end end for R,X in pairs(pages:GetChildren())do if X:FindFirstChild("\078\097\118\105\103\097\116\101\066\117\116\116\111\110\115")then local R=1 local S=0 local V=subPageOrders[X.Name]for u,R in pairs(V)do local V=X[R]if u==1 then X.NavigateButtons.TextLabel.Text=string.upper(R)else S=1 end V.Position=UDim2.new(S,0,V.Position.Y.Scale,0)V.Visible=true end for S,Q in pairs(X.NavigateButtons:GetChildren())do if Q:IsA("\084\101\120\116\066\117\116\116\111\110")then Q.MouseButton1Down:Connect(function()local S=R if Q.Name=="\082\105\103\104\116"then R=R+1 if R>#V then R=1 end elseif Q.Name=="\076\101\102\116"then R=R-1 if R<1 then R=#V end end u(X,S,R,Q.Name)end)end end end end for u,R in pairs(mainFrame.DragBar:GetChildren())do if R:IsA("\084\101\120\116\066\117\116\116\111\110")then R.MouseButton1Down:Connect(function()if guiDe then guiDe=false if R.Name=="\077\105\110\105\109\105\115\101"then if R.TextLabel.Text=="-"then(main.tweenService:Create(pages,TweenInfo.new(.5),{Position=UDim2.new(0,0,-0.8,0)})):Play()R.TextLabel.Text="\043"else pages.Parent.Visible=true;(main.tweenService:Create(pages,TweenInfo.new(.5),{Position=UDim2.new(0,0,.1,0)})):Play()R.TextLabel.Text="-"end elseif R.Name=="\067\108\111\115\101"then module:CloseMainFrame()elseif R.Name=="\066\097\099\107"then tweenPages(UDim2.new(1,0,0,0),pages.Home)end guiDe=true end end)end end

local function navigateNewPage(page, oldPos, newPos, direction, instantTween)
	local tweenTime
	if instantTween then
		tweenTime = 0
	else
		tweenTime = 0.3
	end
	local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	local subPageNames = subPageOrders[page.Name]
	local pageOut
	if tonumber(oldPos) then
		pageOut = page[subPageNames[oldPos]]
	end
	local pageIn = page[subPageNames[newPos]]
	local startX
	if pageOut and pageOut:IsA("ScrollingFrame") then
		pageOut.ScrollBarImageTransparency = 1
	end
	if pageIn:IsA("ScrollingFrame") then
		pageIn.ScrollBarImageTransparency = 0
	end
	local searchBar = page:FindFirstChild("SearchBar")
	if searchBar then
		if pageIn.Size.Y.Scale < 0.85 then
			searchBar.Visible = true
		else
			searchBar.Visible = false
		end
	end
	--
	for i,v in pairs(subPageNames) do
		local subPage = page[v]
		if subPage ~= pageIn and subPage ~= pageOut then
			subPage.Position = UDim2.new(-2,0,subPage.Position.Y.Scale,0)
		end
	end
	--
	if direction == "Right" then
		startX = 1
	elseif direction == "Left" then
		startX = -1
	end
	local endX = startX*-1
	page.NavigateButtons.TextLabel.Text = string.upper(pageIn.Name)
	pageIn.Position = UDim2.new(startX, 0, pageIn.Position.Y.Scale, pageIn.Position.Y.Offset)
	local tweenIn = main.tweenService:Create(pageIn, tweenInfo, {Position = UDim2.new(0,0,pageIn.Position.Y.Scale,0)})
	tweenIn:Play()
	if pageOut then
		local tweenOut = main.tweenService:Create(pageOut, tweenInfo, {Position = UDim2.new(endX,0,pageOut.Position.Y.Scale,0)})
		tweenOut:Play()
		spawn(function()
			tweenOut.Completed:Wait()
			if pageOut.Position.X.Scale == endX then
				pageOut.Position = UDim2.new(-2,0,pageOut.Position.Y.Scale,0)
			end
		end)
	end
end
for a,b in pairs(pages:GetChildren()) do
	if b:FindFirstChild("NavigateButtons") then
		local pos = 1
		local pageX = 0
		local subPages = subPageOrders[b.Name]
		for i,v in pairs(subPages) do
			local subPage = b[v]
			if i == 1 then
				b.NavigateButtons.TextLabel.Text = string.upper(v)
			else
				pageX = 1
			end
			subPage.Position = UDim2.new(pageX,0,subPage.Position.Y.Scale,0)
			subPage.Visible = true
		end
		for c,d in pairs(b.NavigateButtons:GetChildren()) do
			if d:IsA("TextButton") then
				d.MouseButton1Down:Connect(function()
					local oldPos = pos
					if d.Name == "Right" then
						pos = pos + 1
						if pos > #subPages then
							pos = 1
						end
					elseif d.Name == "Left" then
						pos = pos - 1
						if pos < 1 then
							pos = #subPages
						end
					end
					navigateNewPage(b, oldPos, pos, d.Name)
				end)
			end
		end
	end
end

for a,b in pairs(mainFrame.DragBar:GetChildren()) do
	if b:IsA("TextButton") then
		b.MouseButton1Down:Connect(function()
			if guiDe then
				guiDe = false
				if b.Name == "Minimise" then
					if b.TextLabel.Text == "-" then
						main.tweenService:Create(pages, TweenInfo.new(0.5), {Position = UDim2.new(0,0,-0.8,0)}):Play()
						b.TextLabel.Text = "+"
					else
						pages.Parent.Visible = true
						main.tweenService:Create(pages, TweenInfo.new(0.5), {Position = UDim2.new(0,0,0.1,0)}):Play()
						b.TextLabel.Text = "-"
					end
				elseif b.Name == "Close" then
					module:CloseMainFrame()
				elseif b.Name == "Back" then
					tweenPages(UDim2.new(1,0,0,0), pages.Home)
				end
				guiDe = true
			end
		end)
	end
end
		

