local c=require(script.Parent.Parent.Parent.signal)local N=require(script.Parent.Parent.output)local z={}local m=game.Players.LocalPlayer.PlayerGui:FindFirstChild("\077\111\117\115\101\084\114\097\099\107\101\114")or Instance.new("\083\099\114\101\101\110\071\117\105",game.Players.LocalPlayer.PlayerGui)m.Name="\077\111\117\115\101\084\114\097\099\107\101\114"m.ResetOnSpawn=false m.DisplayOrder=2147483647 local function v(...)N.fatal(...)end function z.SetDragger(J,N,z,j)if typeof(N)~="\073\110\115\116\097\110\099\101"then v(("\068\114\097\103\103\101\114\046\083\101\116\068\114\097\103\103\101\114 \058 \065\114\103 \049\040\068\114\097\103\101\114\041 \105\115 \109\117\115\116 \098\101 \071\117\105\066\117\116\116\111\110\040\073\110\115\116\097\110\099\101\041\044 \103\111\116 \037\115"):format(typeof(N)))elseif not N:IsA("\071\117\105\066\117\116\116\111\110")then v(("\068\114\097\103\103\101\114\046\083\101\116\068\114\097\103\103\101\114 \058 \065\114\103 \049\040\068\114\097\103\101\114\041 \105\115 \109\117\115\116 \098\101 \071\117\105\066\117\116\116\111\110\040\073\110\115\116\097\110\099\101\041\044 \103\111\116 \037\115"):format(tostring(N.ClassName)))end if typeof(z)~="\073\110\115\116\097\110\099\101"then v(("\068\114\097\103\103\101\114\046\083\101\116\068\114\097\103\103\101\114 \058 \065\114\103 \050\040\077\097\105\110\041 \105\115 \109\117\115\116 \098\101 \071\117\105\079\098\106\101\099\116\040\073\110\115\116\097\110\099\101\041\044 \103\111\116 \037\115"):format(typeof(z)))elseif not z:IsA("\071\117\105\079\098\106\101\099\116")then v(("\068\114\097\103\103\101\114\046\083\101\116\068\114\097\103\103\101\114 \058 \065\114\103 \050\040\077\097\105\110\041 \105\115 \109\117\115\116 \098\101 \071\117\105\079\098\106\101\099\116\040\073\110\115\116\097\110\099\101\041\044 \103\111\116 \037\115"):format(tostring(z.ClassName)))end if not(typeof(j)=="\102\117\110\099\116\105\111\110"or typeof(j)=="\110\105\108")then v(("\068\114\097\103\103\101\114\046\083\101\116\068\114\097\103\103\101\114 \058 \065\114\103 \051\040\067\104\101\099\107\068\114\097\103\103\097\098\108\101\041 \105\115 \109\117\115\116 \098\101 \102\117\110\099\116\105\111\110\044 \103\111\116 \037\115"):format(typeof(j)))end local d={}local l={}local a=c.new()local s=c.new()d.DragStarted=a d.DragEnded=s local R=Instance.new("\084\101\120\116\066\117\116\116\111\110")R.Text=""R.Name="\077\111\118\101\084\114\097\099\107\101\114"R.Size=UDim2.new(1,6500,1,6500)R.Position=UDim2.new(.5,0,.5,0)R.AnchorPoint=Vector2.new(.5,.5)R.BackgroundTransparency=1 R.ZIndex=999999999 local P=nil l[#l+1]=R.MouseMoved:Connect(function(c,N)if P==nil then R.Parent=script else local m,v=0,0 local j,J=1,1 if z.Parent and z.Parent:IsA("\071\117\105\079\098\106\101\099\116")then m=z.Parent.AbsolutePosition.X v=z.Parent.AbsolutePosition.Y end local d=z.Parent:IsA("\083\099\114\101\101\110\071\117\105")if z.Parent and z.Parent:IsA("\071\117\105\079\098\106\101\099\116")or d then j=z.Parent.AbsoluteSize.X J=z.Parent.AbsoluteSize.Y if d then m=z.Parent.AbsolutePosition.X v=z.Parent.AbsolutePosition.Y end end z.Position=UDim2.new(((c-P.X)-m)/j,0,((N-P.Y)-v)/J,0)end end)local function A()P=nil R.Parent=script s:Fire()end l[#l+1]=R.MouseButton1Up:Connect(A)l[#l+1]=N.MouseButton1Up:Connect(A)l[#l+1]=N.MouseButton1Down:Connect(function(c,z)if j then if not j()then return end end P=Vector2.new(c-N.AbsolutePosition.X,z-N.AbsolutePosition.Y)a:Fire()R.Parent=m end)function d.Destroy(c)for c,N in pairs(l)do if N then N:Disconnect()end end l=nil a:DisconnectAll()a=nil s:DisconnectAll()s=nil if R then R:Destroy()end P=nil d=nil end function d.IsDragging(c)return P~=nil end return d end return z
--- qwreey75
local Signal = require(script.Parent.Parent.Parent.signal)
local Output = require(script.Parent.Parent.output)

local module = {}

local MouseTracker = game.Players.LocalPlayer.PlayerGui:FindFirstChild("MouseTracker")
	or Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
MouseTracker.Name = "MouseTracker"
MouseTracker.ResetOnSpawn = false
MouseTracker.DisplayOrder = 2147483647

local function err(...)
	Output.fatal(...)
end

function module:SetDragger(Drager, Main, CheckDraggable)
	------------------------
	-- Arg Check
	------------------------
	if typeof(Drager) ~= "Instance" then
		err(("Dragger.SetDragger : Arg 1(Drager) is must be GuiButton(Instance), got %s"):format(typeof(Drager)))
	elseif not Drager:IsA("GuiButton") then
		err(
			("Dragger.SetDragger : Arg 1(Drager) is must be GuiButton(Instance), got %s"):format(
				tostring(Drager.ClassName)
			)
		)
	end
	if typeof(Main) ~= "Instance" then
		err(("Dragger.SetDragger : Arg 2(Main) is must be GuiObject(Instance), got %s"):format(typeof(Main)))
	elseif not Main:IsA("GuiObject") then
		err(
			("Dragger.SetDragger : Arg 2(Main) is must be GuiObject(Instance), got %s"):format(tostring(Main.ClassName))
		)
	end
	if not (typeof(CheckDraggable) == "function" or typeof(CheckDraggable) == "nil") then
		err(("Dragger.SetDragger : Arg 3(CheckDraggable) is must be function, got %s"):format(typeof(CheckDraggable)))
	end

	local ReturnTable = {}
	local Connection = {}
	local DragStarted = Signal.new()
	local DragEnded = Signal.new()

	ReturnTable.DragStarted = DragStarted
	ReturnTable.DragEnded = DragEnded

	local Releaser = Instance.new("TextButton")
	Releaser.Text = ""
	Releaser.Name = "MoveTracker"
	Releaser.Size = UDim2.new(1, 6500, 1, 6500)
	Releaser.Position = UDim2.new(0.5, 0, 0.5, 0)
	Releaser.AnchorPoint = Vector2.new(0.5, 0.5)
	Releaser.BackgroundTransparency = 1
	--Releaser.Visible = true
	Releaser.ZIndex = 999999999
	local MouseDownPosition = nil
	Connection[#Connection + 1] = Releaser.MouseMoved:Connect(function(x, y)
		if MouseDownPosition == nil then
			Releaser.Parent = script
		else
			local AbsX, AbsY = 0, 0
			local AbsSizeX, AbsSizeY = 1, 1
			if Main.Parent and Main.Parent:IsA("GuiObject") then
				AbsX = Main.Parent.AbsolutePosition.X
				AbsY = Main.Parent.AbsolutePosition.Y
			end
			local isScreen = Main.Parent:IsA("ScreenGui")
			if Main.Parent and Main.Parent:IsA("GuiObject") or isScreen then
				AbsSizeX = Main.Parent.AbsoluteSize.X
				AbsSizeY = Main.Parent.AbsoluteSize.Y
				if isScreen then
					AbsX = Main.Parent.AbsolutePosition.X
					AbsY = Main.Parent.AbsolutePosition.Y
				end
			end

			Main.Position = UDim2.new(
				(x - MouseDownPosition.X - AbsX) / AbsSizeX,
				0,
				(y - MouseDownPosition.Y - AbsY) / AbsSizeY,
				0
			)
		end
	end)
	local function UnDrag()
		MouseDownPosition = nil
		Releaser.Parent = script
		DragEnded:Fire()
	end
	Connection[#Connection + 1] = Releaser.MouseButton1Up:Connect(UnDrag)
	Connection[#Connection + 1] = Drager.MouseButton1Up:Connect(UnDrag)

	Connection[#Connection + 1] = Drager.MouseButton1Down:Connect(function(x, y)
		if CheckDraggable then
			if not CheckDraggable() then
				return
			end
		end

		MouseDownPosition = Vector2.new(x - Drager.AbsolutePosition.X, y - Drager.AbsolutePosition.Y)
		DragStarted:Fire()
		Releaser.Parent = MouseTracker
	end)

	function ReturnTable:Destroy()
		for _, Connect in pairs(Connection) do
			if Connect then
				Connect:Disconnect()
			end
		end
		Connection = nil

		DragStarted:DisconnectAll()
		DragStarted = nil
		DragEnded:DisconnectAll()
		DragEnded = nil
		if Releaser then
			Releaser:Destroy()
		end

		MouseDownPosition = nil
		ReturnTable = nil
	end

	function ReturnTable:IsDragging()
		return MouseDownPosition ~= nil
	end

	return ReturnTable
end

return module
