local function X(X,l)for X,x in pairs(X:GetDescendants())do if x:IsA("\071\117\105\079\098\106\101\099\116")and x:FindFirstChild("\079\114\105\103\105\110\097\108\090\073\110\100\101\120")==nil then local X=Instance.new("\073\110\116\086\097\108\117\101")X.Name="\079\114\105\103\105\110\097\108\090\073\110\100\101\120"local I=x.ZIndex if l then I=I+10000 end X.Value=I X.Parent=x end end end local function l(X,l)for X,x in pairs(main.commandMenus)do for I,Q in pairs(x:GetDescendants())do if Q:IsA("\071\117\105\079\098\106\101\099\116")then if Q:FindFirstChild("\079\114\105\103\105\110\097\108\090\073\110\100\101\120")and(not l or x==l)then Q.ZIndex=(Q.OriginalZIndex.Value+(X-1)*10)-1000 end end end end end

local function setupOriginalZIndex(frame, forceOnTop)
	for a,b in pairs(frame:GetDescendants()) do
		if b:IsA("GuiObject") and b:FindFirstChild("OriginalZIndex") == nil then
			local iValue = Instance.new("IntValue")
			iValue.Name = "OriginalZIndex"
			local zValue = b.ZIndex
			if forceOnTop then
				zValue = zValue + 10000
			end
			iValue.Value = zValue
			iValue.Parent = b
		end
	end
end
local function updateZIndex(list, specificFrame)
	for i,v in pairs(main.commandMenus) do
		for a,b in pairs(v:GetDescendants()) do
			if b:IsA("GuiObject") then
				if b:FindFirstChild("OriginalZIndex") and (not specificFrame or v == specificFrame) then
					b.ZIndex = b.OriginalZIndex.Value + ((i-1)*10) - 1000
				end
			end
		end
	end
end


