Skip to main content

Draggable

This item only works when running on the client. Client

Properties

Enabled

Draggable.Enabled: boolean

Determines whether the GuiObject is Draggable.

Dragging

Draggable.Dragging: Signal

This property allows you to make a connection with the Connect method. When the user is interacting with or dragging the Draggable GuiObject, this connection will be fired.

See FastSignal for more information.

local draggableObject = Draggable.new(exampleFrame)

draggableObject.Dragging:Connect(function(mousePosition: Vector2)
	print(`Dragging: {mousePosition}`)
end)

Began

Draggable.Began: Signal

This property allows you to make a connection with the Connect method. When the user clicks or touches the Draggable GuiObject, this connection will be fired.

See FastSignal for more information.

local draggableObject = Draggable.new(exampleFrame)

draggableObject.Began:Connect(function(mousePosition: Vector2)
	print(`Began: {mousePosition}`)
end)

Ended

Draggable.Ended: Signal

This property allows you to make a connection with the Connect method. When the user stops interacting with or dragging the Draggable GuiObject, this connection will be fired.

See FastSignal for more information.

local draggableObject = Draggable.new(exampleFrame)

draggableObject.Ended:Connect(function(mousePosition: Vector2)
	print(`Ended: {mousePosition}`)
end)

Boundary

since v1.1.0
</>
Draggable.Boundary: nil | GuiBase2d

This property can be nil or GuiBase2d. It determines the boundary of the Draggable GuiObject.

Functions

new

Draggable.new(guiObjectGuiObject) → Draggable

This function creates a Draggable object, which turns the GuiObject into a Draggable GuiObject.

Destroy

Draggable:Destroy() → ()

Removes the draggable capability from the associated GuiObject. Since v1.1.0, this function is automatically called when the GuiObject is destroyed.

IncludeDescendants

Draggable:IncludeDescendants() → ()

Allows the user to drag the Draggable GuiObject on its descendants.

Include

Draggable:Include(guiObjects{GuiObject}) → ()

This function works similarly to IncludeDescendants, but the developer can pass an array containing specific descendants of the GuiObject to be draggable.

Example:

local draggableObject = Draggable.new(exampleFrame)

local list = [] -- Do not include TextButtons

for i, guiObject in exampleFrame:GetDescendants() do
	if guiObject:IsA("TextButton") then
		continue
	end

	table.insert(list, guiObject)
end

draggableObject:Include(list)
important

Make sure that every element on the list is a GuiObject and that it is a descendant of the Draggable GuiObject.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "This function creates a Draggable object, which turns the GuiObject into a Draggable GuiObject.",
            "params": [
                {
                    "name": "guiObject",
                    "desc": "",
                    "lua_type": "GuiObject"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Draggable"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 27,
                "path": "src/ReplicatedStorage/Draggable/init.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Removes the draggable capability from the associated GuiObject. `Since v1.1.0`, this function is automatically called when the GuiObject is destroyed.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 73,
                "path": "src/ReplicatedStorage/Draggable/init.lua"
            }
        },
        {
            "name": "IncludeDescendants",
            "desc": "Allows the user to drag the Draggable GuiObject on its descendants.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 93,
                "path": "src/ReplicatedStorage/Draggable/init.lua"
            }
        },
        {
            "name": "Include",
            "desc": "This function works similarly to [`IncludeDescendants`](#IncludeDescendants), but the developer can pass an array containing specific descendants of the GuiObject to be draggable.\n\nExample:\n```lua\nlocal draggableObject = Draggable.new(exampleFrame)\n\nlocal list = [] -- Do not include TextButtons\n\nfor i, guiObject in exampleFrame:GetDescendants() do\n\tif guiObject:IsA(\"TextButton\") then\n\t\tcontinue\n\tend\n\n\ttable.insert(list, guiObject)\nend\n\ndraggableObject:Include(list)\n```\n\n:::important\nMake sure that every element on the list is a GuiObject and that it is a descendant of the Draggable GuiObject.\n:::",
            "params": [
                {
                    "name": "guiObjects",
                    "desc": "",
                    "lua_type": "{GuiObject}"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 132,
                "path": "src/ReplicatedStorage/Draggable/init.lua"
            }
        },
        {
            "name": "Dragging",
            "desc": "This is automatically called when the user is interacting with or draggingthe Draggable GuiObject.",
            "params": [
                {
                    "name": "mousePosition",
                    "desc": "",
                    "lua_type": "Vector2"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 138,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Began",
            "desc": "This is automatically called when the user clicks or touches the Draggable GuiObject.",
            "params": [
                {
                    "name": "mousePosition",
                    "desc": "",
                    "lua_type": "Vector2"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 167,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Ended",
            "desc": "This is automatically called when the user stops interacting with or dragging the Draggable GuiObject.",
            "params": [
                {
                    "name": "mousePosition",
                    "desc": "",
                    "lua_type": "Vector2"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 204,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "_mouseOffset",
            "desc": "This property gets the offset of the mouse, and it's GuiObject; this is updated when [`Began`](#Dragging) is called.",
            "lua_type": "Vector2",
            "private": true,
            "source": {
                "line": 19,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "_guiObject",
            "desc": "This is where the GuiObject is stored.",
            "lua_type": "GuiObject",
            "private": true,
            "source": {
                "line": 27,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "_include",
            "desc": "This is where the list of descendants is stored when [`Include`](#Include) or [`IncludeDescendants`](#IncludeDescendants) is called.",
            "lua_type": "{GuiObject}",
            "private": true,
            "source": {
                "line": 35,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "_boundaryCorners",
            "desc": "This property is used to store the corners of the [`boundary`](#Boundary) of the Draggable GuiObject.",
            "lua_type": "nil | {topLeft: Vector2, bottomRight: Vector2}",
            "since": "v1.1.0",
            "private": true,
            "source": {
                "line": 44,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Enabled",
            "desc": "Determines whether the GuiObject is Draggable.",
            "lua_type": "boolean",
            "source": {
                "line": 51,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Dragging",
            "desc": "This property allows you to make a connection with the [`Connect`](https://rblxutils.github.io/FastSignal/api/ScriptSignal/#Connect) method.\nWhen the user is interacting with or dragging the Draggable GuiObject, this connection will be fired.\n\nSee [FastSignal](https://rblxutils.github.io/FastSignal/api/ScriptSignal) for more information.\n\n```lua\nlocal draggableObject = Draggable.new(exampleFrame)\n\ndraggableObject.Dragging:Connect(function(mousePosition: Vector2)\n\tprint(`Dragging: {mousePosition}`)\nend)\n```",
            "lua_type": "Signal",
            "source": {
                "line": 69,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Began",
            "desc": "This property allows you to make a connection with the [`Connect`](https://rblxutils.github.io/FastSignal/api/ScriptSignal/#Connect) method.\nWhen the user clicks or touches the Draggable GuiObject, this connection will be fired.\n\nSee [FastSignal](https://rblxutils.github.io/FastSignal/api/ScriptSignal) for more information.\n\n```lua\nlocal draggableObject = Draggable.new(exampleFrame)\n\ndraggableObject.Began:Connect(function(mousePosition: Vector2)\n\tprint(`Began: {mousePosition}`)\nend)\n```",
            "lua_type": "Signal",
            "source": {
                "line": 87,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Ended",
            "desc": "This property allows you to make a connection with the [`Connect`](https://rblxutils.github.io/FastSignal/api/ScriptSignal/#Connect) method.\nWhen the user stops interacting with or dragging the Draggable GuiObject, this connection will be fired.\n\nSee [FastSignal](https://rblxutils.github.io/FastSignal/api/ScriptSignal) for more information.\n\n```lua\nlocal draggableObject = Draggable.new(exampleFrame)\n\ndraggableObject.Ended:Connect(function(mousePosition: Vector2)\n\tprint(`Ended: {mousePosition}`)\nend)\n```",
            "lua_type": "Signal",
            "source": {
                "line": 105,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        },
        {
            "name": "Boundary",
            "desc": "This property can be nil or GuiBase2d. It determines the boundary of the Draggable GuiObject.",
            "lua_type": "nil | GuiBase2d",
            "since": "v1.1.0",
            "source": {
                "line": 113,
                "path": "src/ReplicatedStorage/Draggable/Prototype.lua"
            }
        }
    ],
    "types": [],
    "name": "Draggable",
    "desc": "",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 15,
        "path": "src/ReplicatedStorage/Draggable/init.lua"
    }
}