return function(e)local C=service.Players.LocalPlayer local D=C.PlayerGui local m=script.Parent.Parent local S=m.Frame local I=m.Frame.TextBox local j=m.Frame.ScrollingFrame local h=m.Frame.PlayerList local P=m.Entry local b=gTable.BindEvent local V=false local U=false local Q=false local l=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=l.SplitKey local E=l.ConsoleKeyCode local f=l.BatchKey local p=client.Remote.Get("\070\111\114\109\097\116\116\101\100\067\111\109\109\097\110\100\115")or{}local O=TweenInfo.new(.15)local M=service.TweenService:Create(S,O,{Size=UDim2.new(1,0,0,140)})local z=service.TweenService:Create(S,O,{Size=UDim2.new(1,0,0,40)})local G=service.TweenService:Create(S,O,{Position=UDim2.new(0,0,0,0)})local K=service.TweenService:Create(S,O,{Position=UDim2.new(0,0,0,-200)})S.Position=UDim2.new(0,0,0,-200)S.Visible=false S.Size=UDim2.new(1,0,0,40)j.Visible=false if client.Variables.ConsoleOpen then if client.Variables.ChatEnabled then service.StarterGui:SetCoreGuiEnabled("\067\104\097\116",true)end if client.Variables.PlayerListEnabled then service.StarterGui:SetCoreGuiEnabled("\080\108\097\121\101\114\076\105\115\116",true)end if client.UI.Get("\078\111\116\105\102")then(client.UI.Get("\078\111\116\105\102",nil,true)).Object.LABEL.Visible=true end local e=client.UI.Get("\067\104\097\116",nil,true)if e then e.Object.Drag.Visible=true end local C=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if C then C.Object.Drag.Visible=true end local D=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if D then D.Object.Frame.Visible=true end end 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 N()if m:IsDescendantOf(game)and not Q then Q=true j:ClearAllChildren()j.CanvasSize=UDim2.new(0,0,0,0)j.ScrollingEnabled=false S.Size=UDim2.new(1,0,0,40)j.Visible=false h.Visible=false scrollOpen=false if client.Variables.ChatEnabled then service.StarterGui:SetCoreGuiEnabled("\067\104\097\116",true)end if client.Variables.PlayerListEnabled then service.StarterGui:SetCoreGuiEnabled("\080\108\097\121\101\114\076\105\115\116",true)end if client.UI.Get("\078\111\116\105\102")then(client.UI.Get("\078\111\116\105\102",nil,true)).Object.LABEL.Visible=true end local e=client.UI.Get("\067\104\097\116",nil,true)if e then e.Object.Drag.Visible=true end local C=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if C then C.Object.Drag.Visible=true end local D=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if D then D.Object.Frame.Visible=true end K:Play()Q=false V=false end end local function r()if m:IsDescendantOf(game)and not Q then Q=true 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")service.StarterGui:SetCoreGuiEnabled("\067\104\097\116",false)service.StarterGui:SetCoreGuiEnabled("\080\108\097\121\101\114\076\105\115\116",false)j.ScrollingEnabled=true h.ScrollingEnabled=true if client.UI.Get("\078\111\116\105\102")then(client.UI.Get("\078\111\116\105\102",nil,true)).Object.LABEL.Visible=false end local e=client.UI.Get("\067\104\097\116",nil,true)if e then e.Object.Drag.Visible=false end local C=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if C then C.Object.Drag.Visible=false end local D=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if D then D.Object.Frame.Visible=false end G:Play()S.Size=UDim2.new(1,0,0,40)j.Visible=false h.Visible=false scrollOpen=false I.Text=""S.Visible=true S.Position=UDim2.new(0,0,0,0)I:CaptureFocus()I.Text=""wait()I.Text=""Q=false V=true end end I.FocusLost:connect(function(e)if e then if I.Text~=""and string.len(I.Text)>1 then client.Remote.Send("\080\114\111\099\101\115\115\067\111\109\109\097\110\100",I.Text)end end N()end)I.Changed:connect(function(e)if e=="\084\101\120\116"and(I.Text~=""and r)then j:ClearAllChildren()h:ClearAllChildren()local e=I.Text if string.match(e,"\046\042"..(f.."\040\091\094\'\093\043\041"))then e=string.match(e,"\046\042"..(f.."\040\091\094\'\093\043\041"))e=string.match(e,"\094\037\115\042\040\046-\041\037\115\042\036")end local C=0 local D=string.match(e,"\046\043"..(o.."\040\046\042\041\036"))for m,S in next,service.Players:GetChildren()do if D and string.sub(string.lower(tostring(S)),1,#D)==string.lower(D)or string.match(e,o.."\036")then local e=P:Clone()e.Text=tostring(S)e.TextXAlignment="\082\105\103\104\116"e.Visible=true e.Parent=h e.Position=UDim2.new(0,0,0,20*C)e.MouseButton1Down:connect(function()I.Text=I.Text..tostring(S)I:CaptureFocus()end)C=C+1 end end h.CanvasSize=UDim2.new(0,0,0,C*20)local m=0 for C,D in next,p do if string.sub(string.lower(D),1,#e)==string.lower(e)or string.find(string.lower(D),string.match(string.lower(e),"\094\040\046-\041"..o)or string.lower(e),1,true)then if not scrollOpen then M:Play()j.Visible=true h.Visible=true scrollOpen=true end local e=P:Clone()e.Visible=true e.Parent=j e.Text=D e.Position=UDim2.new(0,0,0,20*m)e.MouseButton1Down:connect(function()I.Text=e.Text I:CaptureFocus()end)m=m+1 end end S.Size=UDim2.new(1,0,0,math.clamp(m*20+40,40,140))j.CanvasSize=UDim2.new(0,0,0,m*20)elseif e=="\084\101\120\116"and(I.Text==""and V)then z:Play()j.Visible=false h.Visible=false scrollOpen=false j:ClearAllChildren()j.CanvasSize=UDim2.new(0,0,0,0)end end)b(service.UserInputService.InputBegan,function(e)local C=service.UserInputService:GetFocusedTextBox()if not C and(rawequal(e.UserInputType,Enum.UserInputType.Keyboard)and e.KeyCode.Name==(client.Variables.CustomConsoleKey or E))then if V then N()else r()end client.Variables.ConsoleOpen=V 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 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 = UDim2.new(1, 0, 0, 140),
	})

	local scrollCloseTween = service.TweenService:Create(frame, tweenInfo, {
		Size = UDim2.new(1, 0, 0, 40),
	})

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

	local consoleCloseTween = service.TweenService:Create(frame, tweenInfo, {
		Position = UDim2.new(0, 0, 0, -200),
	})

	frame.Position = UDim2.new(0, 0, 0, -200)
	frame.Visible = false
	frame.Size = UDim2.new(1, 0, 0, 40)
	scroll.Visible = false

	if client.Variables.ConsoleOpen then
		if client.Variables.ChatEnabled then
			service.StarterGui:SetCoreGuiEnabled("Chat", true)
		end

		if client.Variables.PlayerListEnabled then
			service.StarterGui:SetCoreGuiEnabled("PlayerList", true)
		end
		if client.UI.Get("Notif") then
			client.UI.Get("Notif", nil, true).Object.LABEL.Visible = true
		end

		local scr = client.UI.Get("Chat", nil, true)
		if scr then
			scr.Object.Drag.Visible = true
		end

		local scr = client.UI.Get("PlayerList", nil, true)
		if scr then
			scr.Object.Drag.Visible = true
		end

		local scr = client.UI.Get("HintHolder", nil, true)
		if scr then
			scr.Object.Frame.Visible = true
		end
	end

	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 = UDim2.new(1, 0, 0, 40)
			scroll.Visible = false
			players.Visible = false
			scrollOpen = false

			if client.Variables.ChatEnabled then
				service.StarterGui:SetCoreGuiEnabled("Chat", true)
			end

			if client.Variables.PlayerListEnabled then
				service.StarterGui:SetCoreGuiEnabled("PlayerList", true)
			end

			if client.UI.Get("Notif") then
				client.UI.Get("Notif", nil, true).Object.LABEL.Visible = true
			end

			local scr = client.UI.Get("Chat", nil, true)
			if scr then
				scr.Object.Drag.Visible = true
			end

			local scr = client.UI.Get("PlayerList", nil, true)
			if scr then
				scr.Object.Drag.Visible = true
			end

			local scr = client.UI.Get("HintHolder", nil, true)
			if scr then
				scr.Object.Frame.Visible = true
			end

			consoleCloseTween:Play()
			--service.SafeTweenPos(frame,UDim2.new(0,0,0,-200),'Out','Linear',0.2,true)
			--frame:TweenPosition(UDim2.new(0,0,0,-200),'Out','Linear',0.2,true)
			debounce = false
			opened = false
		end
	end

	local function open()
		if gui:IsDescendantOf(game) and not debounce then
			debounce = true
			client.Variables.ChatEnabled = service.StarterGui:GetCoreGuiEnabled("Chat")
			client.Variables.PlayerListEnabled = service.StarterGui:GetCoreGuiEnabled("PlayerList")

			service.StarterGui:SetCoreGuiEnabled("Chat", false)
			service.StarterGui:SetCoreGuiEnabled("PlayerList", false)

			scroll.ScrollingEnabled = true
			players.ScrollingEnabled = true

			if client.UI.Get("Notif") then
				client.UI.Get("Notif", nil, true).Object.LABEL.Visible = false
			end

			local scr = client.UI.Get("Chat", nil, true)
			if scr then
				scr.Object.Drag.Visible = false
			end

			local scr = client.UI.Get("PlayerList", nil, true)
			if scr then
				scr.Object.Drag.Visible = false
			end

			local scr = client.UI.Get("HintHolder", nil, true)
			if scr then
				scr.Object.Frame.Visible = false
			end

			consoleOpenTween:Play()

			frame.Size = UDim2.new(1, 0, 0, 40)
			scroll.Visible = false
			players.Visible = false
			scrollOpen = false
			text.Text = ""
			frame.Visible = true
			frame.Position = UDim2.new(0, 0, 0, 0)
			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
			frame.Size = UDim2.new(1, 0, 0, math.clamp((num * 20) + 40, 40, 140))
			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
