Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
DragDetector
Inherits from: ClickDetector → Instance → Object
The DragDetector instance facilitates and encourages interaction with 3D objects in an experience, such as opening doors and drawers, sliding a part around, and much more. Key features include:
Place a
DragDetectorunder anyBasePartorModelto make it draggable via all inputs (mouse, touch, gamepad, and VR), all without a single line of code.Choose from several
DragStyleoptions, define how the object responds to motion viaResponseStyle, and optionally apply axis or movement limits.Scripts can respond to manipulation of dragged objects to drive UI or make logical decisions, such as adjusting the light level in a room based on a sliding wall switch dimmer.
Players can manipulate anchored parts or models and they'll stay exactly where you put them upon release.
DragDetectorswork in Studio as long as you're not using the Select, Move, Scale, or Rotate tools, making it easier to test and adjust draggable objects while editing.
See the 3D Drag Detectors guide for details and usage examples.
Inherits from: ClickDetector
Memory category: Instances
Properties
| Name | Type / Returns | Description |
|---|---|---|
| DragDetector.ActivatedCursorIcon | ContentId | Sets the cursor icon to display when the mouse is activated over the parent of this DragDetector. |
| DragDetector.ActivatedCursorIconContent | Content | Sets the cursor icon to display when the mouse is activated over the parent of this DragDetector. Only supports asset URIs |
| DragDetector.ApplyAtCenterOfMass | boolean | Whether constraint force is applied to the object's center of mass. |
| DragDetector.Axis | Vector3 | The primary axis of motion, expressed relative to the reference frame. |
| DragDetector.DragFrame | CFrame | The CFrame of the pivot, dependent on the drag detector's ReferenceInstance. |
| DragDetector.DragStyle | DragDetectorDragStyle | The paradigm used to generate proposed motion. |
| DragDetector.Enabled | boolean | Whether the DragDetector responds to user input. |
| DragDetector.GamepadModeSwitchKeyCode | KeyCode | During gamepad input, the modifier KeyCode for the secondary mode of motion. |
| DragDetector.KeyboardModeSwitchKeyCode | KeyCode | During keyboard input, the modifier KeyCode for the secondary mode of motion. |
| DragDetector.MaxDragAngle | float | Along with MinDragAngle, impedes the drag detector's attempts to generate motion. |
| DragDetector.MaxDragTranslation | Vector3 | Along with MinDragTranslation, impedes the drag detector's attempts to generate motion. |
| DragDetector.MaxForce | float | Maximum force applied for the object to reach its goal. |
| DragDetector.MaxTorque | float | Maximum torque applied for the object to reach its goal. |
| DragDetector.MinDragAngle | float | Along with MaxDragAngle, impedes the drag detector's attempts to generate motion. |
| DragDetector.MinDragTranslation | Vector3 | Along with MaxDragTranslation, impedes the drag detector's attempts to generate motion. |
| DragDetector.Orientation | Vector3 | Specifies the YXZ rotation of axes of motion relative to the reference frame. |
| DragDetector.PermissionPolicy | DragDetectorPermissionPolicy | Controls the permission level for which players can interact with the DragDetector. |
| DragDetector.ReferenceInstance | Instance | An instance whose CFrame is the reference frame for the drag detector. |
| DragDetector.ResponseStyle | DragDetectorResponseStyle | The paradigm used to move, or not move, the objects affected by the drag detector. |
| DragDetector.Responsiveness | float | Higher values cause the object to reach its goal more rapidly. |
| DragDetector.RunLocally | boolean | Whether user input on a DragDetector replicates to the server or remains local to the specific client. |
| DragDetector.SecondaryAxis | Vector3 | The secondary axis of the motion. |
| DragDetector.TrackballRadialPullFactor | float | If DragStyle is DragDetectorDragStyle.RotateTrackball, multiplier for adding a radial pull rotation as a contribution to the total. |
| DragDetector.TrackballRollFactor | float | If DragStyle is DragDetectorDragStyle.RotateTrackball, multiplier for adding roll rotation to the total. |
| DragDetector.VRSwitchKeyCode | KeyCode | During VR input, the modifier KeyCode for the secondary mode of motion. |
| DragDetector.WorldAxis | Vector3 | The Axis expressed in world space. |
| DragDetector.WorldSecondaryAxis | Vector3 | The SecondaryAxis expressed in world space. |
Inherited from ClickDetector
| Name | Type / Returns | Description |
|---|---|---|
| ClickDetector.CursorIcon | ContentId | Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. |
| ClickDetector.CursorIconContent | Content | Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. Only supports asset URIs. |
| ClickDetector.MaxActivationDistance | float | Maximum distance between a character and the ClickDetector or DragDetector for the player to be able to interact with it. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.Archivable | boolean | Determines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published. |
| Instance.archivable | boolean | |
| Instance.Capabilities | SecurityCapabilities | The set of capabilities allowed to be used for scripts inside this container. |
| Instance.IsInSandbox | boolean | Indicates whether the instance is inside a sandboxed container. |
| Instance.Name | string | A non-unique identifier of the Instance. |
| Instance.Parent | Instance | Determines the hierarchical parent of the Instance. |
| Instance.PredictionMode | PredictionMode | Reflects the client-side prediction mode applied to the instance under server-authoritative physics. |
| Instance.RobloxLocked | boolean | A deprecated property that used to protect CoreGui objects. |
| Instance.Sandboxed | boolean | When enabled, the instance can only access abilities in its Capabilities list. |
| Instance.UniqueId | UniqueId | A unique identifier for the instance. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.ClassName | string | A read-only string representing the class this Object belongs to. |
| Object.className | string |
DragDetector.ActivatedCursorIcon
Sets the cursor icon to display when the mouse is activated over the parent of this DragDetector. If this property is left blank, the detector will use the default icon.
To change the activated cursor icon, set this property to the asset ID of the image you'd like to use.
| Field | Value |
|---|---|
| type | ContentId |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Image |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.ActivatedCursorIconContent
Sets the cursor icon to display when the mouse is activated over the parent of this DragDetector. If this property is left blank, the detector will use the default icon.
To change the activated cursor icon, set this property to the asset ID of the image you'd like to use. Only asset URIs are supported for this property.
| Field | Value |
|---|---|
| type | Content |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Image |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.ApplyAtCenterOfMass
When false (default), constraint force is applied at the point the user clicks on. When true, force is applied at the object's center of mass. Only relevant if ResponseStyle is DragDetectorResponseStyle.Physical and the parent object is unanchored.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Physics Response |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.Axis
The primary axis of motion, expressed relative to the reference frame. For a DragStyle of DragDetectorDragStyle.TranslateLine, the direction of translation; for DragDetectorDragStyle.TranslatePlane, the normal to the plane of motion; for DragDetectorDragStyle.RotateAxis, the axis of 1D rotation. Changing this value automatically updates Orientation and vice versa.
| Field | Value |
|---|---|
| type | Vector3 |
| tags | ["NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Directions |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["Physics","Input"] |
DragDetector.DragFrame
If ReferenceInstance is set, the CFrame of the pivot relative to the reference frame; otherwise, the CFrame of the pivot relative to its frame at the beginning of the drag.
| Field | Value |
|---|---|
| type | CFrame |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Dragged Amount |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.DragStyle
The paradigm used to generate proposed motion, given a stream of cursor rays. See DragDetectorDragStyle for options.
| Field | Value |
|---|---|
| type | DragDetectorDragStyle |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.Enabled
If true, the DragDetector responds to user input; if false, it does not.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.GamepadModeSwitchKeyCode
During gamepad input, the KeyCode for toggling the secondary mode of motion. Only applies if the drag detector's DragStyle has both primary and secondary modes of motion.
| Field | Value |
|---|---|
| type | KeyCode |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Mode Switching |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.KeyboardModeSwitchKeyCode
During keyboard input, the KeyCode for toggling the secondary mode of motion. Only applies if the drag detector's DragStyle has both primary and secondary modes of motion.
| Field | Value |
|---|---|
| type | KeyCode |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Mode Switching |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MaxDragAngle
If this is greater than MinDragAngle, translation will be clamped within that range.
This is not a constraint; it merely impedes the drag detector's attempts to generate motion in order to remain within limits. See AddConstraintFunction() to add custom constraint to a drag.
Only relevant if DragStyle is DragDetectorDragStyle.RotateAxis.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Limits |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MaxDragTranslation
In any dimension, if this is greater than MinDragTranslation, translation will be clamped within that range.
This is not a constraint; it merely impedes the drag detector's attempts to generate motion in order to remain within limits. See AddConstraintFunction() to add custom constraint to a drag.
| Field | Value |
|---|---|
| type | Vector3 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Limits |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MaxForce
Maximum force applied for the object to reach its goal. Only relevant if ResponseStyle is DragDetectorResponseStyle.Physical and the parent object is unanchored.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Physics Response |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MaxTorque
Maximum torque applied for the object to reach its goal. Only relevant if ResponseStyle is DragDetectorResponseStyle.Physical and the parent object is unanchored.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Physics Response |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MinDragAngle
If this is less than MaxDragAngle, translation will be clamped within that range.
This is not a constraint; it merely impedes the drag detector's attempts to generate motion in order to remain within limits. See AddConstraintFunction() to add custom constraint to a drag.
Only relevant if DragStyle is DragDetectorDragStyle.RotateAxis.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Limits |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.MinDragTranslation
In any dimension, if this is less than MaxDragTranslation, translation will be clamped within that range.
This is not a constraint; it merely impedes the drag detector's attempts to generate motion in order to remain within limits. See AddConstraintFunction() to add custom constraint to a drag.
| Field | Value |
|---|---|
| type | Vector3 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Limits |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.Orientation
Specifies the YXZ rotation of axes of motion relative to the reference frame (does not change the orientation of the reference frame itself). Linear translation and axial rotation will be on this reoriented Y axis, and planar translation in the XZ plane. Changing this value automatically updates Axis and vice versa.
| Field | Value |
|---|---|
| type | Vector3 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Directions |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.PermissionPolicy
Controls the permission level for which players can interact with the DragDetector. Default is DragDetectorPermissionPolicy.Everybody.
| Field | Value |
|---|---|
| type | DragDetectorPermissionPolicy |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.ReferenceInstance
An instance whose CFrame is the reference frame for the drag detector. The DragFrame is expressed relative to this CFrame which may be retrieved via the GetReferenceFrame() method.
If this instance is a PVInstance, the reference frame will be its pivot; if an Attachment, then its world CFrame. If it is nil or neither of the former, the reference frame will be based on the pivot of the drag detector's parent BasePart or Model.
| Field | Value |
|---|---|
| type | Instance |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.ResponseStyle
Once the proposed motion has been computed and potentially constrained, this is the paradigm used to move, or not move, the objects affected by the DragDetector. See DragDetectorResponseStyle for options.
| Field | Value |
|---|---|
| type | DragDetectorResponseStyle |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.Responsiveness
Higher values cause the object to reach its goal more rapidly. Only relevant if ResponseStyle is DragDetectorResponseStyle.Physical and the parent object is unanchored.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Physics Response |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.RunLocally
If false (default), the client sends replicated signals (DragStart, DragContinue, DragEnd) to the server which processes cursor rays, makes changes to the data model, and replicates them onwards to clients.
If true, the client processes those signals itself and does not replicate them to the server. Client LocalScripts may be used to respond to these events and RemoteEvents may be used to send any resulting changes that should be replicated to the server.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.SecondaryAxis
The secondary axis of the motion. Relates to orientation using the same paradigm as Attachments.
| Field | Value |
|---|---|
| type | Vector3 |
| tags | ["NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Directions |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["Physics","Input"] |
DragDetector.TrackballRadialPullFactor
When the cursor is outside the trackball, the DragDetector can apply a radial pull rotation that turns the ball as if it were trying to roll out toward the cursor. This property is a 0 to 1 multiplier for adding that rotation as a contribution to the total. Only relevant if DragStyle is DragDetectorDragStyle.RotateTrackball.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.TrackballRollFactor
When the cursor is outside the trackball, the DragDetector can apply a roll rotation that turns the ball as if it were mounted on a vinyl record facing the viewer. This property is a 0 to 1 multiplier for adding that roll rotation to the total. Only relevant if DragStyle is DragDetectorDragStyle.RotateTrackball.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.VRSwitchKeyCode
During VR input, the KeyCode for toggling the secondary mode of motion. Only applies if the drag detector's DragStyle has both primary and secondary modes of motion.
| Field | Value |
|---|---|
| type | KeyCode |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Mode Switching |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Physics","Input"] |
DragDetector.WorldAxis
The Axis expressed in world space. Relates to orientation using the same paradigm as Attachments.
| Field | Value |
|---|---|
| type | Vector3 |
| tags | ["NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Directions |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["Physics","Input"] |
DragDetector.WorldSecondaryAxis
The SecondaryAxis expressed in world space. Relates to orientation using the same paradigm as Attachments.
| Field | Value |
|---|---|
| type | Vector3 |
| tags | ["NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Drag Directions |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["Physics","Input"] |
Methods
| Name | Type / Returns | Description |
|---|---|---|
| DragDetector:AddConstraintFunction | RBXScriptConnection | Adds a function to modify or constrain proposed motion. |
| DragDetector:GetReferenceFrame | CFrame | Returns the reference CFrame in which motion is expressed. |
| DragDetector:RestartDrag | () | May be invoked from a script to restart the drag using new parameters. |
| DragDetector:SetDragStyleFunction | () | Passes a function to be used if and only if DragStyle is set to DragDetectorDragStyle.Scriptable. |
| DragDetector:SetPermissionPolicyFunction | () | Passes a function to be used if and only if PermissionPolicy is set to DragDetectorPermissionPolicy.Scriptable. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance:AddTag | () | Applies a tag to the instance. |
| Instance:children | Instances | Returns an array of the object's children. |
| Instance:ClearAllChildren | () | This method destroys all of an instance's children. |
| Instance:Clone | Instance | Create a copy of an instance and all its descendants, ignoring instances that are not Archivable. |
| Instance:clone | Instance | |
| Instance:Destroy | () | Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children. |
| Instance:destroy | () | |
| Instance:FindFirstAncestor | Instance? | Returns the first ancestor of the Instance whose Instance.Name is equal to the given name. |
| Instance:FindFirstAncestorOfClass | Instance? | Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className. |
| Instance:FindFirstAncestorWhichIsA | Instance? | Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstChild | Instance? | Returns the first child of the Instance found with the given name. |
| Instance:findFirstChild | Instance | |
| Instance:FindFirstChildOfClass | Instance? | Returns the first child of the Instance whose ClassName is equal to the given class name. |
| Instance:FindFirstChildWhichIsA | Instance? | Returns the first child of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstDescendant | Instance? | Returns the first descendant found with the given Instance.Name. |
| Instance:GetActor | Actor? | Returns the Actor associated with the Instance, if any. |
| Instance:GetAttribute | Variant | Returns the value which has been assigned to the given attribute name. |
| Instance:GetAttributeChangedSignal | RBXScriptSignal | Returns an event that fires when the given attribute changes. |
| Instance:GetAttributes | Dictionary | Returns a dictionary of the instance's attributes. |
| Instance:GetChildren | Instances | Returns an array containing all of the instance's children. |
| Instance:getChildren | Instances | |
| Instance:GetDebugId | string | Returns a coded string of the debug ID used internally by Roblox. |
| Instance:GetDescendants | Instances | Returns an array containing all of the descendants of the instance. |
| Instance:GetFullName | string | Returns a string describing the instance's ancestry. |
| Instance:GetStyled | Variant | Returns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified. |
| Instance:GetStyledPropertyChangedSignal | RBXScriptSignal | Returns an event that fires when the given style property changes on the instance. |
| Instance:GetTags | Array | Gets an array of all tags applied to the instance. |
| Instance:HasTag | boolean | Check whether the instance has a given tag. |
| Instance:IsAncestorOf | boolean | Returns true if an Instance is an ancestor of the given descendant. |
| Instance:IsDescendantOf | boolean | Returns true if an Instance is a descendant of the given ancestor. |
| Instance:isDescendantOf | boolean | |
| Instance:IsPropertyModified | boolean | Returns true if the value stored in the specified property is not equal to the code-instantiated default. |
| Instance:QueryDescendants | Instances | Returns an array containing all descendants of the instance that match the selector string. |
| Instance:Remove | () | Sets the object's Parent to nil, and does the same for all its descendants. |
| Instance:remove | () | |
| Instance:RemoveTag | () | Removes a tag from the instance. |
| Instance:ResetPropertyToDefault | () | Resets a property to its default value. |
| Instance:SetAttribute | () | Sets the attribute with the given name to the given value. |
| Instance:WaitForChild | Instance | Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object:GetPropertyChangedSignal | RBXScriptSignal | Get an event that fires when a given property of the object changes. |
| Object:IsA | boolean | Returns true if an object's class matches or inherits from a given class. |
| Object:isA | boolean |
DragDetector:AddConstraintFunction
Adds a function to modify or constrain proposed motion. The function takes an input CFrame of proposed motion and returns a CFrame of modified or unmodified motion. Both the input and output are expressed relative to the reference frame. You can add multiple functions which will be called in order by priority, passing the results along in a chain.
To remove an added constraint function, call Disconnect() on the returned connection object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| priority | int | The order of priority for functions added via this method. Higher values take precedence over lower values. | |
| function | Function | Function for modifying or constraining proposed motion. This function takes an input CFrame of proposed motion and returns a CFrame of modified or unmodified motion, both relative to the reference frame. |
Returns
| Type | Description |
|---|---|
| RBXScriptConnection | Use this connection object to remove the constraint function. |
| Field | Value |
|---|---|
| security | None |
| thread safety | Unsafe |
| capabilities | ["Physics","Input"] |
DragDetector:GetReferenceFrame
Returns the reference CFrame in which motion is expressed; see the ReferenceInstance property for more details.
Returns
| Type | Description |
|---|---|
| CFrame | The reference CFrame in which motion is expressed. |
| Field | Value |
|---|---|
| security | None |
| thread safety | Unsafe |
| capabilities | ["Physics","Input"] |
DragDetector:RestartDrag
May be invoked from a script to restart the drag using new parameters, if parameters such as DragStyle, Axis, or SecondaryAxis change.
Returns
| Type | Description |
|---|---|
| () |
| Field | Value |
|---|---|
| security | None |
| thread safety | Unsafe |
| capabilities | ["Physics","Input"] |
DragDetector:SetDragStyleFunction
Passes a function to be used if and only if DragStyle is set to DragDetectorDragStyle.Scriptable. The given function is called when responding to a DragContinue signal, it receives the signal's world space cursor ray with type Ray, and it returns a CFrame containing the desired location and orientation of the pivot in world space.
If the function returns nil, the object will not be moved. This is useful if the script has not yet collected all the information it needs to give the correct answer, or in temporary cases where you want the object to stay where it is.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| function | Function | Function for monitoring DragContinue signals. This function receives the signal's world space cursor ray and it returns a CFrame containing the desired location and orientation of the pivot in world space. If this function returns nil, the object will not be moved. |
Returns
| Type | Description |
|---|---|
| () |
| Field | Value |
|---|---|
| security | None |
| thread safety | Unsafe |
| capabilities | ["Physics","Input"] |
DragDetector:SetPermissionPolicyFunction
Passes a function to be used if and only if PermissionPolicy is set to DragDetectorPermissionPolicy.Scriptable. The given function accepts a Player parameter for enabling/disabling the detector for a specific player. It also receives a part parameter indicating which specific BasePart was clicked, such as one part within a draggable Model; this is useful for enabling/disabling the detector based on that part's Name, Color, HasTag() value, or other details.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| function | Function | Function for setting the detector's interactivity. This function accepts a Player parameter for enabling/disabling the detector for a specific player. It also receives a part parameter indicating which specific BasePart was clicked, such as one part within a draggable Model; this is useful for enabling/disabling the detector based on that part's Name, Color, HasTag() value, or other details. |
Returns
| Type | Description |
|---|---|
| () |
| Field | Value |
|---|---|
| security | None |
| thread safety | Unsafe |
| capabilities | ["Physics","Input"] |
Code samples: View on Creator Hub (DragDetector-SetPermissionPolicyFunction).
Events
| Name | Type / Returns | Description |
|---|---|---|
| DragDetector.DragContinue | Fires when a user continues dragging the object after DragStart has been initiated. | |
| DragDetector.DragEnd | Fires when a user stops dragging the object. | |
| DragDetector.DragStart | Fires when a user starts dragging the object. |
Inherited from ClickDetector
| Name | Type / Returns | Description |
|---|---|---|
| ClickDetector.MouseClick | Fires when a player interacts with the parent of a ClickDetector or DragDetector. | |
| ClickDetector.mouseClick | ||
| ClickDetector.MouseHoverEnter | Fires when the parent of a ClickDetector or DragDetector is hovered over by a player. | |
| ClickDetector.MouseHoverLeave | Fires when a player's cursor hovers off the parent of a ClickDetector or DragDetector. | |
| ClickDetector.RightMouseClick | Fires when a player right clicks their mouse cursor on a ClickDetector or DragDetector. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.AncestryChanged | Fires when the Instance.Parent property of this object or one of its ancestors is changed. | |
| Instance.AttributeChanged | Fires whenever an attribute is changed on the Instance. | |
| Instance.ChildAdded | Fires after an object is parented to this Instance. | |
| Instance.childAdded | ||
| Instance.ChildRemoved | Fires after a child is removed from this Instance. | |
| Instance.DescendantAdded | Fires after a descendant is added to the Instance. | |
| Instance.DescendantRemoving | Fires immediately before a descendant of the Instance is removed. | |
| Instance.Destroying | Fires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy(). | |
| Instance.StyledPropertiesChanged | Fires whenever any style property is changed on the instance, including when a property is set to nil. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.Changed | Fires immediately after a property of the object changes, with some limitations. |
DragDetector.DragContinue
Fires when a user continues dragging the object after DragStart has been initiated.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| playerWhoDragged | Player | The Player who initiated the drag through DragStart and is now continuing the drag. | |
| cursorRay | Ray | Ray emanating from the cursor, aimed into the scene. | |
| viewFrame | CFrame | CFrame of the user's Camera. | |
| vrInputFrame | OptionalCoordinateFrame | If using a VR input device, the CFrame of the hand holding the cursor/pointer/controller. | |
| isModeSwitchKeyDown | boolean | If the drag detector's DragStyle has both primary and secondary modes of motion, this parameter indicates whether the user is pressing the modifier input defined through KeyboardModeSwitchKeyCode, GamepadModeSwitchKeyCode, or VRSwitchKeyCode. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Physics","Input"] |
DragDetector.DragEnd
Fires when a user stops dragging the object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| playerWhoDragged | Player | The Player who initiated the drag through DragStart and has now ended (released) the drag. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Physics","Input"] |
DragDetector.DragStart
Fires when a user starts dragging the object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| playerWhoDragged | Player | Player who initiated the drag. | |
| cursorRay | Ray | Ray emanating from the cursor, aimed into the scene. | |
| viewFrame | CFrame | CFrame of the user's Camera. | |
| hitFrame | CFrame | The hit frame of the cursor raycast that initiated the drag. | |
| clickedPart | BasePart | The part that was hit by the cursor raycast that initiated the drag. | |
| vrInputFrame | OptionalCoordinateFrame | If using a VR input device, the CFrame of the hand holding the cursor/pointer/controller. | |
| isModeSwitchKeyDown | boolean | If the drag detector's DragStyle has both primary and secondary modes of motion, this parameter indicates whether the user is pressing the modifier input defined through KeyboardModeSwitchKeyCode, GamepadModeSwitchKeyCode, or VRSwitchKeyCode. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Physics","Input"] |