We used to have a property called Draggable which allowed us to enable dragging on GUI objects. Unfortunately this has been deprecated and is no longer available. That’s why I created an easy to use module to replace the old ‘Draggable’ property.
This module can be used on any GuiObject (Frames, ImageLabels, TextLabels, etc.) and supports both mouse and touch.
How To Use
First, you require the module and use DraggableObject.new(Object) function to create a new draggable object from an existing GuiObject.
local DraggableObject = require(script.Parent.DraggableObject) local FrameDrag = DraggableObject.new(script.Parent.Frame)
Then, to enable dragging all you have to do is just call the :Enable() method:
And now your frame should be draggable! To force disable dragging you can simply call:
Connecting To Events
This module also allows you to connect 3 different event handlers including DragStarted, Dragged, and DragEnded. Here’s an example:
FrameDrag.DragStarted = function() print("User has started dragging the frame") end FrameDrag.Dragged = function(ObjPosition) print("Frame is currently at", ObjPosition) end FrameDrag.DragEnded = function() print("User has stopped dragging the frame") end
Hope this helps! If you guys have any comments or suggestions, please post them down below.