Skip to Content
Kinemium

UIDragDetector

Let a GUI element be dragged with the pointer.

UIDragDetector adds pointer dragging to its parent GUI object. Drag mode, response style, axis, translation bounds, and angle bounds control the result.

Getting started

local detector = Instance.new("UIDragDetector")
detector.DragStyle = Enum.UIDragDetectorDragStyle.TranslatePlane
detector.ResponseStyle = Enum.UIDragDetectorResponseStyle.Offset
detector.Parent = panel

detector.DragStart:Connect(function()
    print("drag began")
end)

Properties

PropertyTypeAccessDefaultDescription
EnabledbooleanRead/writetrueWhether dragging is allowed.
DragStyleEnum.UIDragDetectorDragStyleRead/writeTranslatePlaneTranslation or rotation dragging.
ResponseStyleEnum.UIDragDetectorResponseStyleRead/writeOffsetWhether the parent's position or another property changes.
DragAxisVector2Read/write(1, 0)Axis used by constrained dragging.
MinDragTranslationUDim2Read/writeZeroMinimum translation.
MaxDragTranslationUDim2Read/writeZeroMaximum translation.
MinDragAnglenumberRead/write0Minimum rotation in degrees.
MaxDragAnglenumberRead/write0Maximum rotation in degrees.

Events

EventArgumentsDescription
DragStartpointer positionFires when a drag begins.
DragContinuepointer positionFires on each pointer move while dragging.
DragEndpointer positionFires when the drag ends.

Notes

  • The parent must be a GuiObject; otherwise the detector is skipped.
  • Disabling the detector while dragging cancels the drag.
  • Translation limits only apply when at least one of the min or max values is non-zero.
  • Rotation limits apply when the drag style rotates the parent.
  • Cloning copies the configuration and clears any in-progress drag.

See also

  • GuiObject for the parent element.
  • UIListLayout and UIGridLayout if the parent is laid out automatically.

On this page