function Controller.UpdateSelections()local Q=0 local x=0 for n,Z in ipairs(playerGui:GetChildren())do if Z.ClassName=="\083\099\114\101\101\110\071\117\105"then if Z.Enabled==true and(Z.DisplayOrder>x and(Z.Name~="\067\104\097\116"and Z.Name~="\073\110\102\111 \079\118\101\114\108\097\121"))then local n=false local function N(x)if n==false then for x,Z in ipairs(x:GetChildren())do Q=Q+1 if Q%300==0 then _L.Services.RunService.Stepped:wait()end if Z:IsA("\071\117\105\079\098\106\101\099\116")then if Z.Visible==true then if Z.ClassName=="\073\109\097\103\101\066\117\116\116\111\110"or Z.ClassName=="\084\101\120\116\066\117\116\116\111\110"or Z.ClassName=="\084\101\120\116\066\111\120"then n=true return end N(Z)end end end end end N(Z)if n then x=Z.DisplayOrder end end end end local function n(Z)for Z,N in ipairs(Z:GetChildren())do if N then if N.ClassName=="\073\109\097\103\101\066\117\116\116\111\110"or N.ClassName=="\084\101\120\116\066\117\116\116\111\110"or N.ClassName=="\084\101\120\116\066\111\120"then if not blacklistSet then if N.Selectable==false then selectionBlacklist[N]=true end end if selectionBlacklist[N]==nil then local n=true if N.ClassName=="\073\109\097\103\101\066\117\116\116\111\110"and N.ImageTransparency==1 or N.Visible==false then n=false else local function Z(N)Q=Q+1 if Q%300==0 then _L.Services.RunService.Stepped:wait()end local g=N.Parent pcall(function()if g.Visible==false then n=false end end)pcall(function()if g.ClassName=="\083\099\114\101\101\110\071\117\105"and(g.Enabled==false or g.DisplayOrder<x)then n=false end end)pcall(function()if g.ClassName=="\083\117\114\102\097\099\101\071\117\105"or g.ClassName=="\066\105\108\108\098\111\097\114\100\071\117\105"then n=false end end)if n==true then if g~=nil and g~=playerGui then Z(g)end end end Z(N)end N.Selectable=N:FindFirstAncestor("\084\117\116\111\114\105\097\108")~=nil and true or n end else pcall(function()N.Selectable=false end)end n(N)end end end n(playerGui)blacklistSet=true end



function Controller.UpdateSelections()
	local iteration = 0
	---
	local highestZ = 0
	for _, screenGui in ipairs(playerGui:GetChildren()) do
		if screenGui.ClassName == "ScreenGui" then
			if screenGui.Enabled == true and screenGui.DisplayOrder > highestZ and screenGui.Name ~= "Chat" and screenGui.Name ~= "Info Overlay" then
				local buttonVisible = false
				local function scanElement (p)
					if buttonVisible == false then
						for _, v in ipairs(p:GetChildren()) do
							iteration = iteration + 1
							if iteration%300 == 0 then
								_L.Services.RunService.Stepped:wait()
							end
							if v:IsA("GuiObject") then
								if v.Visible == true then
									if v.ClassName == "ImageButton" or v.ClassName == "TextButton" or v.ClassName == "TextBox" then
										buttonVisible = true
										return
									end
									scanElement(v)
								end
							end
						end
					end
				end
				scanElement(screenGui)
				if buttonVisible then
					highestZ = screenGui.DisplayOrder
				end
			end
		end
	end
	---
	local function scan(parent)
		for _, child in ipairs(parent:GetChildren()) do
			if child then
				if child.ClassName == "ImageButton" or child.ClassName == "TextButton" or child.ClassName == "TextBox" then
					if not blacklistSet then
						if child.Selectable == false then
							selectionBlacklist[child] = true
						end
					end
					
					if selectionBlacklist[child] == nil then
						local selectable = true
						if (child.ClassName == "ImageButton" and child.ImageTransparency == 1) or child.Visible == false then
							--- Blunt test
							selectable = false
						else
							--- Parent test
							local function scanParent(p1)
								iteration = iteration + 1
								if iteration%300 == 0 then
									_L.Services.RunService.Stepped:wait()
								end
								local p2 = p1.Parent
								pcall(function()  if p2.Visible == false then  selectable = false  end  end)
								pcall(function()  if p2.ClassName == "ScreenGui" and (p2.Enabled == false or p2.DisplayOrder < highestZ) then  selectable = false  end  end)
								pcall(function()  if p2.ClassName == "SurfaceGui" or p2.ClassName == "BillboardGui" then  selectable = false  end  end)
								if selectable == true then
									if p2 ~= nil and p2 ~= playerGui then
										scanParent(p2)
									end
								end
							end
							scanParent(child)
						end
						child.Selectable = child:FindFirstAncestor("Tutorial") ~= nil and true or selectable
					end
				else
					pcall(function()  child.Selectable = false  end)
				end
				scan(child)
			end
		end
	end
	---
	scan(playerGui)
	blacklistSet = true
end

