local function o(o,M)o.MouseLeave:connect(function(o,U)M.Visible=false end)o.MouseMoved:connect(function(U,k)M.Label.Text=o.Desc.Value M.Size=UDim2.new(0,10000,0,10000)local v=M.Label.TextBounds.X local q=math.floor(v/500)q=q+1 if q<1 then q=1 end local m=500 if v<500 then m=v end M.Visible=true M.Size=UDim2.new(0,m+5,0,q*20+5)M.Position=UDim2.new(0,U,0,(k-40)-(q*20+5))end)end return function(M)local U=M.gTable local k=U.Object local v=k.Drag local q=k.Drag.Main local m=k.Drag.Close local A=k.Drag.Hide local l=k.Drag.Search local W=k.Drag.Main.ClientTab local N=k.Drag.Main.ServerTab local S=k.Drag.Main.Dragger local J=k.Drag.Main.Client local Q=k.Drag.Main.Server local z=k.Drag.Title local s=k.Entry local g=k.Desc local V=0 local c=service.Players.LocalPlayer:GetMouse()local x,f=v.AbsoluteSize.X,q.AbsoluteSize.Y local E=false local w,F=x,f local O=""local function L()Q.Visible=false J.Visible=true W.BackgroundTransparency=0 N.BackgroundTransparency=.5 end local function C()Q.Visible=true J.Visible=false W.BackgroundTransparency=.5 N.BackgroundTransparency=0 end local y y=function()local M local U=service.GetTasks()J:ClearAllChildren()local k=0 for M,U in pairs(U)do local v=s:Clone()local q=v.Frame local m=U:Status()v.Parent=J v.Visible=true v.Desc.Value=U.Name v.Position=UDim2.new(0,0,0,k*20)q.Text.Text=tostring(U.Function)q.Status.Text=m if m=="\115\117\115\112\101\110\100\101\100"then q.Resume.Text="\082\101\115\117\109\101"elseif m=="\110\111\114\109\097\108"or m=="\114\117\110\110\105\110\103"then q.Resume.Text="\083\117\115\112\101\110\100"end q.Resume.MouseButton1Down:connect(function()if q.Resume.Text=="\082\101\115\117\109\101"and U:Status()=="\083\117\115\112\101\110\100\101\100"then U:Resume()else U:Pause()end wait(.5)y()end)q.Kill.MouseButton1Down:connect(function()U:Kill()wait(.5)y()end)q.Stop.MouseButton1Down:connect(function()U:Stop()wait(.5)y()end)o(v,g)k=k+1 end J.CanvasSize=UDim2.new(0,0,0,V*20)end N.MouseButton1Down:connect(C)W.MouseButton1Down:connect(L)m.MouseButton1Click:connect(function()v.Draggable=false v:TweenPosition(UDim2.new(v.Position.X.Scale,v.Position.X.Offset,1,0),"\079\117\116","\083\105\110\101",.5,true)wait(.5)U:Destroy()end)v.BackgroundColor3=q.BackgroundColor3 A.MouseButton1Click:connect(function()if q.Visible then q.Visible=false v.BackgroundTransparency=q.BackgroundTransparency A.Text="\043"else q.Visible=true v.BackgroundTransparency=1 A.Text="-"end end)c.Move:connect(function(o,M)if E then x=w+(S.Position.X.Offset+20)f=F+(S.Position.Y.Offset+20)if x<200 then x=200 end if f<200 then f=200 end v.Size=UDim2.new(0,x,0,30)q.Size=UDim2.new(1,0,0,f)if x<220 then if O==""then O=z.Text end z.Text=""else if O~=""then z.Text=O O=""end end end end)S.DragBegin:connect(function(o)E=true end)S.DragStopped:connect(function(o,M)E=false w=x F=f S.Position=UDim2.new(1,-20,1,-20)end)U:Ready()while wait(1)do y()end end
--// All global vars will be wiped/replaced except script
local function Expand(ent, point)
	ent.MouseLeave:connect(function(x, y)
		point.Visible = false
	end)

	ent.MouseMoved:connect(function(x, y)
		point.Label.Text = ent.Desc.Value
		point.Size = UDim2.new(0, 10000, 0, 10000)
		local bounds = point.Label.TextBounds.X
		local rows = math.floor(bounds / 500)
		rows = rows + 1
		if rows < 1 then
			rows = 1
		end
		local newx = 500
		if bounds < 500 then
			newx = bounds
		end
		point.Visible = true
		point.Size = UDim2.new(0, newx + 5, 0, (rows * 20) + 5)
		point.Position = UDim2.new(0, x, 0, y - 40 - ((rows * 20) + 5))
	end)
end

return function(data)
	local gTable = data.gTable
	local gui = gTable.Object
	local drag = gui.Drag
	local Main = gui.Drag.Main
	local Close = gui.Drag.Close
	local Hide = gui.Drag.Hide
	local Search = gui.Drag.Search
	local cTab = gui.Drag.Main.ClientTab
	local sTab = gui.Drag.Main.ServerTab
	local Dragger = gui.Drag.Main.Dragger
	local cFrame = gui.Drag.Main.Client
	local sFrame = gui.Drag.Main.Server
	local Title = gui.Drag.Title
	local Entry = gui.Entry
	local Desc = gui.Desc

	local num = 0
	local mouse = service.Players.LocalPlayer:GetMouse()
	local nx, ny = drag.AbsoluteSize.X, Main.AbsoluteSize.Y
	local dragging = false
	local defx, defy = nx, ny
	local topText = ""

	local function openClient()
		sFrame.Visible = false
		cFrame.Visible = true
		cTab.BackgroundTransparency = 0
		sTab.BackgroundTransparency = 0.5
	end

	local function openServer()
		sFrame.Visible = true
		cFrame.Visible = false
		cTab.BackgroundTransparency = 0.5
		sTab.BackgroundTransparency = 0
	end

	local updateLists
	updateLists = function()
		local serverTasks --= client.Remote.Get("TaskCommand","GetTasks")
		local clientTasks = service.GetTasks() --service.Threads.Tasks
		--// Unfinished
		cFrame:ClearAllChildren()

		local cNum = 0
		for index, task in pairs(clientTasks) do
			local new = Entry:Clone()
			local frame = new.Frame
			local status = task:Status()
			new.Parent = cFrame
			new.Visible = true
			new.Desc.Value = task.Name
			new.Position = UDim2.new(0, 0, 0, cNum * 20)
			frame.Text.Text = tostring(task.Function)
			frame.Status.Text = status

			if status == "suspended" then
				frame.Resume.Text = "Resume"
			elseif status == "normal" or status == "running" then
				frame.Resume.Text = "Suspend"
			end

			frame.Resume.MouseButton1Down:connect(function()
				if frame.Resume.Text == "Resume" and task:Status() == "Suspended" then
					task:Resume()
				else
					task:Pause()
				end
				wait(0.5)
				updateLists()
			end)

			frame.Kill.MouseButton1Down:connect(function()
				task:Kill()
				wait(0.5)
				updateLists()
			end)

			frame.Stop.MouseButton1Down:connect(function()
				task:Stop()
				wait(0.5)
				updateLists()
			end)

			Expand(new, Desc)
			cNum = cNum + 1
		end

		cFrame.CanvasSize = UDim2.new(0, 0, 0, num * 20)
	end

	sTab.MouseButton1Down:connect(openServer)
	cTab.MouseButton1Down:connect(openClient)

	Close.MouseButton1Click:connect(function()
		drag.Draggable = false
		drag:TweenPosition(UDim2.new(drag.Position.X.Scale, drag.Position.X.Offset, 1, 0), "Out", "Sine", 0.5, true)
		wait(0.5)
		gTable:Destroy()
	end)

	drag.BackgroundColor3 = Main.BackgroundColor3

	Hide.MouseButton1Click:connect(function()
		if Main.Visible then
			Main.Visible = false
			drag.BackgroundTransparency = Main.BackgroundTransparency
			Hide.Text = "+"
		else
			Main.Visible = true
			drag.BackgroundTransparency = 1
			Hide.Text = "-"
		end
	end)

	mouse.Move:connect(function(x, y)
		if dragging then
			nx = defx + (Dragger.Position.X.Offset + 20)
			ny = defy + (Dragger.Position.Y.Offset + 20)
			if nx < 200 then
				nx = 200
			end
			if ny < 200 then
				ny = 200
			end
			drag.Size = UDim2.new(0, nx, 0, 30)
			Main.Size = UDim2.new(1, 0, 0, ny)
			if nx < 220 then
				if topText == "" then
					topText = Title.Text
				end
				Title.Text = ""
			else
				if topText ~= "" then
					Title.Text = topText
					topText = ""
				end
			end
		end
	end)

	Dragger.DragBegin:connect(function(init)
		dragging = true
	end)

	Dragger.DragStopped:connect(function(x, y)
		dragging = false
		defx = nx
		defy = ny
		Dragger.Position = UDim2.new(1, -20, 1, -20)
	end)

	gTable:Ready()

	while wait(1) do
		updateLists()
	end
end
