return function(a)local G=service.Players.LocalPlayer local h=G.PlayerGui local J=script.Parent.Parent local e=J.Frame local m=J.Frame.TextBox local N=J.Frame.ScrollingFrame local b=J.Frame.PlayerList local o=J.Entry local k=gTable.BindEvent local d=false local r=false local M=false local g=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 Y=g.SplitKey local t=g.ConsoleKeyCode local T=g.BatchKey local p=client.Remote.Get("\070\111\114\109\097\116\116\101\100\067\111\109\109\097\110\100\115")or{}e.Position=UDim2.new(0,0,0,-200)e.Visible=false e.Size=UDim2.new(1,0,0,40)N.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 a=client.UI.Get("\067\104\097\116",nil,true)if a then a.Object.Drag.Visible=true end local G=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if G then G.Object.Drag.Visible=true end local h=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if h then h.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 C()if J:IsDescendantOf(game)and not M then M=true N:ClearAllChildren()N.CanvasSize=UDim2.new(0,0,0,0)N.ScrollingEnabled=false e.Size=UDim2.new(1,0,0,40)N.Visible=false b.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 a=client.UI.Get("\067\104\097\116",nil,true)if a then a.Object.Drag.Visible=true end local G=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if G then G.Object.Drag.Visible=true end local h=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if h then h.Object.Frame.Visible=true end service.SafeTweenPos(e,UDim2.new(0,0,0,-200),"\079\117\116","\076\105\110\101\097\114",.2,true)M=false d=false end end local function w()if J:IsDescendantOf(game)and not M then M=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)N.ScrollingEnabled=true b.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 a=client.UI.Get("\067\104\097\116",nil,true)if a then a.Object.Drag.Visible=false end local G=client.UI.Get("\080\108\097\121\101\114\076\105\115\116",nil,true)if G then G.Object.Drag.Visible=false end local h=client.UI.Get("\072\105\110\116\072\111\108\100\101\114",nil,true)if h then h.Object.Frame.Visible=false end e.Size=UDim2.new(1,0,0,40)N.Visible=false b.Visible=false scrollOpen=false m.Text=""e.Visible=true e.Position=UDim2.new(0,0,0,0)m:CaptureFocus()m.Text=""wait()m.Text=""M=false d=true end end m.FocusLost:connect(function(a)if a then if m.Text~=""and string.len(m.Text)>1 then client.Remote.Send("\080\114\111\099\101\115\115\067\111\109\109\097\110\100",m.Text)end C()end end)m.Changed:connect(function(a)if a=="\084\101\120\116"and(m.Text~=""and w)then N:ClearAllChildren()b:ClearAllChildren()local a=m.Text if string.match(a,"\046\042"..(T.."\040\091\094\'\093\043\041"))then a=string.match(a,"\046\042"..(T.."\040\091\094\'\093\043\041"))a=string.match(a,"\094\037\115\042\040\046-\041\037\115\042\036")end local G=0 local h=string.match(a,"\046\043"..(Y.."\040\046\042\041\036"))for J,e in next,service.Players:GetChildren()do if h and string.sub(string.lower(tostring(e)),1,#h)==string.lower(h)or string.match(a,Y.."\036")then local a=o:Clone()a.Text=tostring(e)a.TextXAlignment="\082\105\103\104\116"a.Visible=true a.Parent=b a.Position=UDim2.new(0,0,0,20*G)a.MouseButton1Down:connect(function()m.Text=m.Text..tostring(e)m:CaptureFocus()end)G=G+1 end end b.CanvasSize=UDim2.new(0,0,0,G*20)local J=0 for G,h in next,p do if string.sub(string.lower(h),1,#a)==string.lower(a)or string.find(string.lower(h),string.match(string.lower(a),"\094\040\046-\041"..Y)or string.lower(a))then if not scrollOpen then e.Size=UDim2.new(1,0,0,330)N.Visible=true b.Visible=true scrollOpen=true end local a=o:clone()a.Visible=true a.Parent=N a.Text=h a.Position=UDim2.new(0,0,0,20*J)a.MouseButton1Down:connect(function()m.Text=a.Text m:CaptureFocus()end)J=J+1 end end N.CanvasSize=UDim2.new(0,0,0,J*20)elseif a=="\084\101\120\116"and(m.Text==""and d)then service.SafeTweenSize(e,UDim2.new(1,0,0,40),nil,nil,.3,nil,function()if scrollOpen then e.Size=UDim2.new(1,0,0,140)end end)N.Visible=false b.Visible=false scrollOpen=false N:ClearAllChildren()N.CanvasSize=UDim2.new(0,0,0,0)end end)k(service.UserInputService.InputBegan,function(a)local G=service.UserInputService:GetFocusedTextBox()if not G and(rawequal(a.UserInputType,Enum.UserInputType.Keyboard)and a.KeyCode.Name==(client.Variables.CustomConsoleKey or t))then if d then C()else w()end client.Variables.ConsoleOpen=d end end)gTable:Ready()end


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 {}
		
	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
			
			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
					
			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
			close()
		end
	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)) then
					if not scrollOpen then
						frame.Size = UDim2.new(1,0,0,330)
						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
			scroll.CanvasSize = UDim2.new(0,0,0,num*20)
		elseif c == 'Text' and text.Text == '' and opened then
			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
