return function(x)local k=service.Players.LocalPlayer local i=k.PlayerGui local L=script.Parent.Parent local E=L.Frame local s=L.Frame.TextBox local y=L.Frame.ScrollingFrame local B=L.Frame.PlayerList local b=L.Entry local I=gTable.BindEvent local T=false local v=false local J=false local o=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","\080\114\101\102\105\120"})local h=o.SplitKey local P=o.ConsoleKeyCode local w=o.BatchKey local c=o.Prefix local S=client.Remote.Get("\070\111\114\109\097\116\116\101\100\067\111\109\109\097\110\100\115")or{}local l=UDim2.new(.36,0,0,200)local N=UDim2.new(.36,0,0,47)local U=UDim2.new(.32,0,.353,0)local d=UDim2.new(.32,0,0,-200)local p=TweenInfo.new(.15)local z=service.TweenService:Create(E,p,{Size=l})local t=service.TweenService:Create(E,p,{Size=N})local a=service.TweenService:Create(E,p,{Position=U})local A=service.TweenService:Create(E,p,{Position=d})E.Position=d E.Visible=false E.Size=N y.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 g()if L:IsDescendantOf(game)and not J then J=true y:ClearAllChildren()y.CanvasSize=UDim2.new(0,0,0,0)y.ScrollingEnabled=false E.Size=N y.Visible=false B.Visible=false scrollOpen=false A:Play()J=false T=false end end local function j()if L:IsDescendantOf(game)and not J then J=true y.ScrollingEnabled=true B.ScrollingEnabled=true a:Play()E.Size=N y.Visible=false B.Visible=false scrollOpen=false s.Text=""E.Visible=true E.Position=U s:CaptureFocus()s.Text=""wait()s.Text=""J=false T=true end end s.FocusLost:Connect(function(x)if x then if s.Text~=""and string.len(s.Text)>1 then client.Remote.Send("\080\114\111\099\101\115\115\067\111\109\109\097\110\100",s.Text)end end g()end)s.Changed:Connect(function(x)if x=="\084\101\120\116"and(s.Text~=""and j)then if string.sub(s.Text,string.len(s.Text))=="\t"then if B:FindFirstChild("\069\110\116\114\121 \048")then s.Text=(string.sub(s.Text,1,string.len(s.Text)-1)..B["\069\110\116\114\121 \048"].Text).." "elseif y:FindFirstChild("\069\110\116\114\121 \048")then s.Text=(string.split(y["\069\110\116\114\121 \048"].Text,"\060"))[1]else s.Text=s.Text..c end s.CursorPosition=string.len(s.Text)+1 s.Text=string.gsub(s.Text,"\t","")end y:ClearAllChildren()B:ClearAllChildren()local x=s.Text if string.match(x,"\046\042"..(w.."\040\091\094\'\093\043\041"))then x=string.match(x,"\046\042"..(w.."\040\091\094\'\093\043\041"))x=string.match(x,"\094\037\115\042\040\046-\041\037\115\042\036")end local k=0 local i=string.match(x,"\046\043"..(h.."\040\046\042\041\036"))for L,E in next,service.Players:GetPlayers()do if i and string.sub(string.lower(tostring(E)),1,#i)==string.lower(i)or string.match(x,h.."\036")then local x=b:Clone()x.Text=tostring(E)x.Name="\069\110\116\114\121 "..k x.TextXAlignment="\082\105\103\104\116"x.Visible=true x.Parent=B x.Position=UDim2.new(0,0,0,20*k)x.MouseButton1Down:Connect(function()s.Text=s.Text..tostring(E)s:CaptureFocus()end)k=k+1 end end B.CanvasSize=UDim2.new(0,0,0,k*20)local L=0 for k,i in next,S do if string.sub(string.lower(i),1,#x)==string.lower(x)or string.find(string.lower(i),string.match(string.lower(x),"\094\040\046-\041"..h)or string.lower(x),1,true)then if not scrollOpen then z:Play()y.Visible=true B.Visible=true scrollOpen=true end local x=b:Clone()x.Visible=true x.Parent=y x.Text=i x.Name="\069\110\116\114\121 "..L x.Position=UDim2.new(0,0,0,20*L)x.MouseButton1Down:Connect(function()s.Text=x.Text s:CaptureFocus()end)L=L+1 end end if L>0 then E.Size=UDim2.new(.36,0,0,math.clamp(math.max(L,k)*20+53,47,200))else B.Visible=false E.Size=N end y.CanvasSize=UDim2.new(0,0,0,L*20)elseif x=="\084\101\120\116"and(s.Text==""and T)then t:Play()y.Visible=false B.Visible=false scrollOpen=false y:ClearAllChildren()y.CanvasSize=UDim2.new(0,0,0,0)end end)I(service.UserInputService.InputBegan,function(x)local k=service.UserInputService:GetFocusedTextBox()if not k and(rawequal(x.UserInputType,Enum.UserInputType.Keyboard)and x.KeyCode.Name==(client.Variables.CustomConsoleKey or P))then if T then g()else j()end client.Variables.ConsoleOpen=T 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", "Prefix" })
	local splitKey = settings.SplitKey
	local consoleKey = settings.ConsoleKeyCode
	local batchKey = settings.BatchKey
	local prefix = settings.Prefix
	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
			if string.sub(text.Text, string.len(text.Text)) == "	" then
				if players:FindFirstChild("Entry 0") then
					text.Text = (string.sub(text.Text, 1, (string.len(text.Text) - 1)) .. players["Entry 0"].Text)
						.. " "
				elseif scroll:FindFirstChild("Entry 0") then
					text.Text = string.split(scroll["Entry 0"].Text, "<")[1]
				else
					text.Text = text.Text .. prefix
				end
				text.CursorPosition = string.len(text.Text) + 1
				text.Text = string.gsub(text.Text, "	", "")
			end
			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:GetPlayers() 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.Name = "Entry " .. pNum
					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.Name = "Entry " .. num
					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
