DraggableObject - Styxling/Feather GitHub Wiki

This module enables dragging for GUI elements using both mouse and touch inputs. It provides a simple way to add draggable functionality to any GuiObject.

Overview

  • Draggable Functionality:
    Allows any GuiObject to be dragged by the user.

  • Event Callbacks:
    Optional events that can be set:

    • DragStarted: Called when dragging begins.
    • Dragged: Called continuously as the object is dragged, providing the updated position.
    • DragEnded: Called when dragging stops.

Usage:

  1. Create a draggable object:
    local DraggableObject = require(Directory("_replicated", "DraggableGUI"))
    local myDraggable = DraggableObject.new(myGuiObject)
    
  2. Enable dragging:
    myDraggable:Enable()
    
  3. Optionally, set up your callback functions:
    myDraggable.DragStarted = function()
        print("Drag started")
    end
    
    myDraggable.Dragged = function(newPosition)
        print("Dragging at position:", newPosition)
    end
    
    myDraggable.DragEnded = function()
        print("Drag ended")
    end
    
  4. To disable dragging, call:
    myDraggable:Disable()
    

Additional Information

For more detailed instructions, visit the original documentation on the Roblox DevForum.

Credit: Original implementation by Spynaz.