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