local function a(a)local U=false local q local y local function i(i,T)U=true q=a.AbsolutePosition y=Vector2.new(i,T)-q end local function T(q,i)if U then a.Position=UDim2.new(0,q-y.X,0,i-y.Y)end end local function v(a,q)U=false end a.InputBegan:Connect(function(a)if a.UserInputType==Enum.UserInputType.MouseButton1 then i(a.Position.X,a.Position.Y)end end)a.InputChanged:Connect(function(a)if a.UserInputType==Enum.UserInputType.MouseMovement then T(a.Position.X,a.Position.Y)end end)a.InputEnded:Connect(function(a)if a.UserInputType==Enum.UserInputType.MouseButton1 then v(a.Position.X,a.Position.Y)end end)end

local function enableDragging(button)
	local dragging = false
	local dragStartPos
	local offset
	local function onMouseButton1Down(x, y)
		dragging = true
		dragStartPos = button.AbsolutePosition
		offset = Vector2.new(x, y) - dragStartPos
	end
	local function onMouseMove(x, y)
		if dragging then
			button.Position = UDim2.new(0, x - offset.X, 0, y - offset.Y)
		end
	end
	local function onMouseButton1Up(x, y)
		dragging = false
	end
	button.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			onMouseButton1Down(input.Position.X, input.Position.Y)
		end
	end)
	button.InputChanged:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseMovement then
			onMouseMove(input.Position.X, input.Position.Y)
		end
	end)
	button.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			onMouseButton1Up(input.Position.X, input.Position.Y)
		end
	end)
end
