return function(z)local c=service.Players.LocalPlayer local I=c.PlayerGui local u=script.Parent.Parent local F=u.Frame local P=u.Frame.TextBox local S=u.Frame.ScrollingFrame local R=u.Frame.PlayerList local q=u.Entry local U=gTable.BindEvent local b=false local C=false local Y=false local K=client.Remote.Get("\083\101\116\116\105\110\103",{"\083\112\108\105\116\075\101\121","\067\111\110\115\111\108\101\075\101\121\067\111\100\101","\066\097\116\099\104\075\101\121"})local o=K.SplitKey local N=K.ConsoleKeyCode local B=K.BatchKey local D=client.Remote.Get("\070\111\114\109\097\116\116\101\100\067\111\109\109\097\110\100\115")or{}local X=UDim2.new(.36,0,0,200)local s=UDim2.new(.36,0,0,47)local x=UDim2.new(.32,0,.353,0)local f=UDim2.new(.32,0,0,-200)local w=TweenInfo.new(.15)local e=service.TweenService:Create(F,w,{Size=X})local J=service.TweenService:Create(F,w,{Size=s})local v=service.TweenService:Create(F,w,{Position=x})local n=service.TweenService:Create(F,w,{Position=f})F.Position=f F.Visible=false F.Size=s S.Visible=false client.Variables.ChatEnabled=service.StarterGui:GetCoreGuiEnabled("\067\104\097\116")client.Variables.PlayerListEnabled=service.StarterGui:GetCoreGuiEnabled("\080\108\097\121\101\114\076\105\115\116")local function d()if u:IsDescendantOf(game)and not Y then Y=true S:ClearAllChildren()S.CanvasSize=UDim2.new(0,0,0,0)S.ScrollingEnabled=false F.Size=s S.Visible=false R.Visible=false scrollOpen=false n:Play()Y=false b=false end end local function V()if u:IsDescendantOf(game)and not Y then Y=true S.ScrollingEnabled=true R.ScrollingEnabled=true v:Play()F.Size=s S.Visible=false R.Visible=false scrollOpen=false P.Text=""F.Visible=true F.Position=x P:CaptureFocus()P.Text=""wait()P.Text=""Y=false b=true end end P.FocusLost:connect(function(z)if z then if P.Text~=""and string.len(P.Text)>1 then client.Remote.Send("\080\114\111\099\101\115\115\067\111\109\109\097\110\100",P.Text)end end d()end)P.Changed:connect(function(z)if z=="\084\101\120\116"and(P.Text~=""and V)then S:ClearAllChildren()R:ClearAllChildren()local z=P.Text if string.match(z,"\046\042"..(B.."\040\091\094\'\093\043\041"))then z=string.match(z,"\046\042"..(B.."\040\091\094\'\093\043\041"))z=string.match(z,"\094\037\115\042\040\046-\041\037\115\042\036")end local c=0 local I=string.match(z,"\046\043"..(o.."\040\046\042\041\036"))for u,F in next,service.Players:GetChildren()do if I and string.sub(string.lower(tostring(F)),1,#I)==string.lower(I)or string.match(z,o.."\036")then local z=q:Clone()z.Text=tostring(F)z.TextXAlignment="\082\105\103\104\116"z.Visible=true z.Parent=R z.Position=UDim2.new(0,0,0,20*c)z.MouseButton1Down:connect(function()P.Text=P.Text..tostring(F)P:CaptureFocus()end)c=c+1 end end R.CanvasSize=UDim2.new(0,0,0,c*20)local u=0 for c,I in next,D do if string.sub(string.lower(I),1,#z)==string.lower(z)or string.find(string.lower(I),string.match(string.lower(z),"\094\040\046-\041"..o)or string.lower(z),1,true)then if not scrollOpen then e:Play()S.Visible=true R.Visible=true scrollOpen=true end local z=q:Clone()z.Visible=true z.Parent=S z.Text=I z.Position=UDim2.new(0,0,0,20*u)z.MouseButton1Down:connect(function()P.Text=z.Text P:CaptureFocus()end)u=u+1 end end if u>0 then F.Size=UDim2.new(.36,0,0,math.clamp(math.max(u,c)*20+53,47,200))else R.Visible=false F.Size=s end S.CanvasSize=UDim2.new(0,0,0,u*20)elseif z=="\084\101\120\116"and(P.Text==""and b)then J:Play()S.Visible=false R.Visible=false scrollOpen=false S:ClearAllChildren()S.CanvasSize=UDim2.new(0,0,0,0)end end)U(service.UserInputService.InputBegan,function(z)local c=service.UserInputService:GetFocusedTextBox()if not c and(rawequal(z.UserInputType,Enum.UserInputType.Keyboard)and z.KeyCode.Name==(client.Variables.CustomConsoleKey or N))then if b then d()else V()end client.Variables.ConsoleOpen=b end end)gTable:Ready()end
--// All global vars will be wiped/replaced except script
--// All guis are autonamed codeName..gui.Name

return function(data)
	local player = service.Players.LocalPlayer
	local playergui = player.PlayerGui
	local gui = script.Parent.Parent
	local frame = gui.Frame
	local text = gui.Frame.TextBox
	local scroll = gui.Frame.ScrollingFrame
	local players = gui.Frame.PlayerList
	local entry = gui.Entry
	local BindEvent = gTable.BindEvent

	local opened = false
	local scrolling = false
	local debounce = false
	local settings = client.Remote.Get("Setting", { "SplitKey", "ConsoleKeyCode", "BatchKey" })
	local splitKey = settings.SplitKey
	local consoleKey = settings.ConsoleKeyCode
	local batchKey = settings.BatchKey
	local commands = client.Remote.Get("FormattedCommands") or {}

	local scrollOpenSize = UDim2.new(0.36, 0, 0, 200)
	local scrollCloseSize = UDim2.new(0.36, 0, 0, 47)

	local openPos = UDim2.new(0.32, 0, 0.353, 0)
	local closePos = UDim2.new(0.32, 0, 0, -200)

	local tweenInfo = TweenInfo.new(0.15) ----service.SafeTweenSize(frame,UDim2.new(1,0,0,40),nil,nil,0.3,nil,function() if scrollOpen then frame.Size = UDim2.new(1,0,0,140) end end)
	local scrollOpenTween = service.TweenService:Create(frame, tweenInfo, {
		Size = scrollOpenSize,
	})

	local scrollCloseTween = service.TweenService:Create(frame, tweenInfo, {
		Size = scrollCloseSize,
	})

	local consoleOpenTween = service.TweenService:Create(frame, tweenInfo, {
		Position = openPos,
	})

	local consoleCloseTween = service.TweenService:Create(frame, tweenInfo, {
		Position = closePos,
	})

	frame.Position = closePos
	frame.Visible = false
	frame.Size = scrollCloseSize
	scroll.Visible = false

	client.Variables.ChatEnabled = service.StarterGui:GetCoreGuiEnabled("Chat")
	client.Variables.PlayerListEnabled = service.StarterGui:GetCoreGuiEnabled("PlayerList")

	local function close()
		if gui:IsDescendantOf(game) and not debounce then
			debounce = true
			scroll:ClearAllChildren()
			scroll.CanvasSize = UDim2.new(0, 0, 0, 0)
			scroll.ScrollingEnabled = false
			frame.Size = scrollCloseSize
			scroll.Visible = false
			players.Visible = false
			scrollOpen = false

			consoleCloseTween:Play()

			debounce = false
			opened = false
		end
	end

	local function open()
		if gui:IsDescendantOf(game) and not debounce then
			debounce = true

			scroll.ScrollingEnabled = true
			players.ScrollingEnabled = true

			consoleOpenTween:Play()

			frame.Size = scrollCloseSize
			scroll.Visible = false
			players.Visible = false
			scrollOpen = false
			text.Text = ""
			frame.Visible = true
			frame.Position = openPos
			text:CaptureFocus()
			text.Text = ""
			wait()
			text.Text = ""
			debounce = false
			opened = true
		end
	end

	text.FocusLost:connect(function(enterPressed)
		if enterPressed then
			if text.Text ~= "" and string.len(text.Text) > 1 then
				client.Remote.Send("ProcessCommand", text.Text)
			end
		end

		close()
	end)

	text.Changed:connect(function(c)
		if c == "Text" and text.Text ~= "" and open then
			scroll:ClearAllChildren()
			players:ClearAllChildren()

			local nText = text.Text
			if string.match(nText, ".*" .. batchKey .. "([^']+)") then
				nText = string.match(nText, ".*" .. batchKey .. "([^']+)")
				nText = string.match(nText, "^%s*(.-)%s*$")
			end

			local pNum = 0
			local pMatch = string.match(nText, ".+" .. splitKey .. "(.*)$")
			for i, v in next, service.Players:GetChildren() do
				if
					(pMatch and string.sub(string.lower(tostring(v)), 1, #pMatch) == string.lower(pMatch))
					or string.match(nText, splitKey .. "$")
				then
					local new = entry:Clone()
					new.Text = tostring(v)
					new.TextXAlignment = "Right"
					new.Visible = true
					new.Parent = players
					new.Position = UDim2.new(0, 0, 0, 20 * pNum)
					new.MouseButton1Down:connect(function()
						text.Text = text.Text .. tostring(v)
						text:CaptureFocus()
					end)
					pNum = pNum + 1
				end
			end

			players.CanvasSize = UDim2.new(0, 0, 0, pNum * 20)

			local num = 0
			for i, v in next, commands do
				if
					string.sub(string.lower(v), 1, #nText) == string.lower(nText)
					or string.find(
						string.lower(v),
						string.match(string.lower(nText), "^(.-)" .. splitKey) or string.lower(nText),
						1,
						true
					)
				then
					if not scrollOpen then
						scrollOpenTween:Play()
						--frame.Size = UDim2.new(1,0,0,140)
						scroll.Visible = true
						players.Visible = true
						scrollOpen = true
					end
					local b = entry:Clone()
					b.Visible = true
					b.Parent = scroll
					b.Text = v
					b.Position = UDim2.new(0, 0, 0, 20 * num)
					b.MouseButton1Down:connect(function()
						text.Text = b.Text
						text:CaptureFocus()
					end)
					num = num + 1
				end
			end

			if num > 0 then
				frame.Size = UDim2.new(0.36, 0, 0, math.clamp((math.max(num, pNum) * 20) + 53, 47, 200))
			else
				players.Visible = false
				frame.Size = scrollCloseSize
			end
			scroll.CanvasSize = UDim2.new(0, 0, 0, num * 20)
		elseif c == "Text" and text.Text == "" and opened then
			scrollCloseTween:Play()
			--service.SafeTweenSize(frame,UDim2.new(1,0,0,40),nil,nil,0.3,nil,function() if scrollOpen then frame.Size = UDim2.new(1,0,0,140) end end)
			scroll.Visible = false
			players.Visible = false
			scrollOpen = false
			scroll:ClearAllChildren()
			scroll.CanvasSize = UDim2.new(0, 0, 0, 0)
		end
	end)

	BindEvent(service.UserInputService.InputBegan, function(InputObject)
		local textbox = service.UserInputService:GetFocusedTextBox()
		if
			not textbox
			and rawequal(InputObject.UserInputType, Enum.UserInputType.Keyboard)
			and InputObject.KeyCode.Name == (client.Variables.CustomConsoleKey or consoleKey)
		then
			if opened then
				close()
			else
				open()
			end
			client.Variables.ConsoleOpen = opened
		end
	end)

	gTable:Ready()
end
