# DragDetector

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [ClickDetector](https://rapi.sleaze.dev/classes/ClickDetector.md), [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/DragDetector/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/DragDetector

Instance which facilitates and encourages interaction with 3D objects in an experience.

## Properties

### DragStyle

```luau
DragDetector.DragStyle: Enum.DragDetectorDragStyle = Enum.DragDetectorDragStyle.TranslatePlane
```

- Tags: Read capabilities: Input + Physics

The paradigm used to generate proposed motion.

### Enabled

```luau
DragDetector.Enabled: boolean = true
```

- Tags: Read capabilities: Input + Physics

Whether the [`DragDetector`](https://rapi.sleaze.dev/classes/DragDetector.md) responds to user input.

### PermissionPolicy

```luau
DragDetector.PermissionPolicy: Enum.DragDetectorPermissionPolicy = Enum.DragDetectorPermissionPolicy.Everybody
```

- Tags: Read capabilities: Input + Physics

Controls the permission level for which players can interact with the [`DragDetector`](https://rapi.sleaze.dev/classes/DragDetector.md).

### ResponseStyle

```luau
DragDetector.ResponseStyle: Enum.DragDetectorResponseStyle = Enum.DragDetectorResponseStyle.Physical
```

- Tags: Read capabilities: Input + Physics

The paradigm used to move, or not move, the objects affected by the drag detector.

### RunLocally

```luau
DragDetector.RunLocally: boolean = false
```

- Tags: Read capabilities: Input + Physics

Whether user input on a [`DragDetector`](https://rapi.sleaze.dev/classes/DragDetector.md) replicates to the server or remains local to the specific client.

### TrackballRadialPullFactor

```luau
DragDetector.TrackballRadialPullFactor: number = 1
```

- Tags: Read capabilities: Input + Physics

If [`DragStyle`](https://rapi.sleaze.dev/classes/DragDetector.md) is `DragDetectorDragStyle.RotateTrackball`, multiplier for adding a radial pull rotation as a contribution to the total.

### TrackballRollFactor

```luau
DragDetector.TrackballRollFactor: number = 1
```

- Tags: Read capabilities: Input + Physics

If [`DragStyle`](https://rapi.sleaze.dev/classes/DragDetector.md) is `DragDetectorDragStyle.RotateTrackball`, multiplier for adding roll rotation to the total.

### ReferenceInstance

```luau
DragDetector.ReferenceInstance: Instance
```

- Tags: Read capabilities: Input + Physics

An instance whose [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) is the reference frame for the drag detector.

### Axis

```luau
DragDetector.Axis: Vector3 = Vector3.new(0, 1, 0)
```

- Tags: Not replicated, Read capabilities: Input + Physics, Load only

The primary axis of motion, expressed relative to the reference frame.

### Orientation

```luau
DragDetector.Orientation: Vector3 = Vector3.new(-0, 180, 90)
```

- Tags: Read capabilities: Input + Physics

Specifies the **YXZ** rotation of axes of motion relative to the reference frame.

### SecondaryAxis

```luau
DragDetector.SecondaryAxis: Vector3 = Vector3.new(1, 0, 0)
```

- Tags: Not replicated, Read capabilities: Input + Physics, Load only

The secondary axis of the motion.

### WorldAxis

```luau
DragDetector.WorldAxis: Vector3 = Vector3.new(0, 1, 0)
```

- Tags: Not replicated, Read capabilities: Input + Physics, Load only

The [`Axis`](https://rapi.sleaze.dev/classes/DragDetector.md) expressed in world space.

### WorldSecondaryAxis

```luau
DragDetector.WorldSecondaryAxis: Vector3 = Vector3.new(1, 0, 0)
```

- Tags: Not replicated, Read capabilities: Input + Physics, Load only

The [`SecondaryAxis`](https://rapi.sleaze.dev/classes/DragDetector.md) expressed in world space.

### MaxDragAngle

```luau
DragDetector.MaxDragAngle: number = 0
```

- Tags: Read capabilities: Input + Physics

Along with [`MinDragAngle`](https://rapi.sleaze.dev/classes/DragDetector.md), impedes the drag detector's attempts to generate motion.

### MaxDragTranslation

```luau
DragDetector.MaxDragTranslation: Vector3 = Vector3.zero
```

- Tags: Read capabilities: Input + Physics

Along with [`MinDragTranslation`](https://rapi.sleaze.dev/classes/DragDetector.md), impedes the drag detector's attempts to generate motion.

### MinDragAngle

```luau
DragDetector.MinDragAngle: number = 0
```

- Tags: Read capabilities: Input + Physics

Along with [`MaxDragAngle`](https://rapi.sleaze.dev/classes/DragDetector.md), impedes the drag detector's attempts to generate motion.

### MinDragTranslation

```luau
DragDetector.MinDragTranslation: Vector3 = Vector3.zero
```

- Tags: Read capabilities: Input + Physics

Along with [`MaxDragTranslation`](https://rapi.sleaze.dev/classes/DragDetector.md), impedes the drag detector's attempts to generate motion.

### DragFrame

```luau
DragDetector.DragFrame: CFrame = CFrame.identity
```

- Tags: Read capabilities: Input + Physics

The [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) of the pivot, dependent on the drag detector's [`ReferenceInstance`](https://rapi.sleaze.dev/classes/DragDetector.md).

### ActivatedCursorIcon

```luau
DragDetector.ActivatedCursorIcon: string = ""
```

- Tags: Read capabilities: Input + Physics

Sets the cursor icon to display when the mouse is activated over the parent of this [`DragDetector`](https://rapi.sleaze.dev/classes/DragDetector.md).

### ActivatedCursorIconContent

```luau
DragDetector.ActivatedCursorIconContent: Content
```

- Tags: Read capabilities: Input + Physics

Sets the cursor icon to display when the mouse is activated over the parent of this [`DragDetector`](https://rapi.sleaze.dev/classes/DragDetector.md). Only supports asset URIs

### PhysicalDragClickedPart

```luau
DragDetector.PhysicalDragClickedPart: Instance
```

- Tags: Hidden, Not scriptable, Read capabilities: Input + Physics

### PhysicalDragHitPoint

```luau
DragDetector.PhysicalDragHitPoint: Vector3 = Vector3.zero
```

- Tags: Hidden, Not scriptable, Read capabilities: Input + Physics

### PhysicalDragIsInVR

```luau
DragDetector.PhysicalDragIsInVR: boolean = false
```

- Tags: Hidden, Not scriptable, Read capabilities: Input + Physics

### PhysicalDragTargetFrame

```luau
DragDetector.PhysicalDragTargetFrame: CFrame = CFrame.identity
```

- Tags: Hidden, Not scriptable, Read capabilities: Input + Physics

### GamepadModeSwitchKeyCode

```luau
DragDetector.GamepadModeSwitchKeyCode: Enum.KeyCode = Enum.KeyCode.ButtonR1
```

- Tags: Read capabilities: Input + Physics

During gamepad input, the modifier `KeyCode` for the secondary mode of motion.

### KeyboardModeSwitchKeyCode

```luau
DragDetector.KeyboardModeSwitchKeyCode: Enum.KeyCode = Enum.KeyCode.LeftControl
```

- Tags: Read capabilities: Input + Physics

During keyboard input, the modifier `KeyCode` for the secondary mode of motion.

### VRSwitchKeyCode

```luau
DragDetector.VRSwitchKeyCode: Enum.KeyCode = Enum.KeyCode.ButtonL2
```

- Tags: Read capabilities: Input + Physics

During VR input, the modifier `KeyCode` for the secondary mode of motion.

### ApplyAtCenterOfMass

```luau
DragDetector.ApplyAtCenterOfMass: boolean = false
```

- Tags: Read capabilities: Input + Physics

Whether constraint force is applied to the object's center of mass.

### MaxForce

```luau
DragDetector.MaxForce: number = 10000000
```

- Tags: Read capabilities: Input + Physics

Maximum force applied for the object to reach its goal.

### MaxTorque

```luau
DragDetector.MaxTorque: number = 10000
```

- Tags: Read capabilities: Input + Physics

Maximum torque applied for the object to reach its goal.

### Responsiveness

```luau
DragDetector.Responsiveness: number = 10
```

- Tags: Read capabilities: Input + Physics

Higher values cause the object to reach its goal more rapidly.

## Methods

### AddConstraintFunction

```luau
DragDetector:AddConstraintFunction(priority: number, function: (...any) -> ...any): RBXScriptConnection
```

- Tags: Capabilities: Input + Physics

Adds a function to modify or constrain proposed motion.

Parameters:

- `priority`: The order of priority for functions added via this method. Higher values take precedence over lower values.
- `function`: Function for modifying or constraining proposed motion. This function takes an input [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) of **proposed** motion and returns a [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) of **modified** or unmodified motion, both relative to the reference frame.

Returns: Use this connection object to remove the constraint function.

### GetReferenceFrame

```luau
DragDetector:GetReferenceFrame(): CFrame
```

- Tags: Capabilities: Input + Physics

Returns the reference [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) in which motion is expressed.

Returns: The reference [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) in which motion is expressed.

### RestartDrag

```luau
DragDetector:RestartDrag()
```

- Tags: Capabilities: Input + Physics

May be invoked from a script to restart the drag using new parameters.

### SetDragStyleFunction

```luau
DragDetector:SetDragStyleFunction(function: (...any) -> ...any)
```

- Tags: Capabilities: Input + Physics

Passes a function to be used if and only if [`DragStyle`](https://rapi.sleaze.dev/classes/DragDetector.md) is set to `DragDetectorDragStyle.Scriptable`.

Parameters:

- `function`: Function for monitoring [`DragContinue`](https://rapi.sleaze.dev/classes/DragDetector.md) signals. This function receives the signal's world space cursor ray and it returns a [`CFrame`](https://rapi.sleaze.dev/index/types/CFrame.md) containing the desired location and orientation of the pivot in world space. If this function returns `nil`, the object will not be moved.

### SetPermissionPolicyFunction

```luau
DragDetector:SetPermissionPolicyFunction(function: (...any) -> ...any)
```

- Tags: Capabilities: Input + Physics

Passes a function to be used if and only if [`PermissionPolicy`](https://rapi.sleaze.dev/classes/DragDetector.md) is set to `DragDetectorPermissionPolicy.Scriptable`.

Parameters:

- `function`: Function for setting the detector's interactivity. This function accepts a [`Player`](https://rapi.sleaze.dev/classes/Player.md) parameter for enabling/disabling the detector for a specific player. It also receives a `part` parameter indicating which specific [`BasePart`](https://rapi.sleaze.dev/classes/BasePart.md) was clicked, such as one part within a draggable [`Model`](https://rapi.sleaze.dev/classes/Model.md); this is useful for enabling/disabling the detector based on that part's [`Name`](https://rapi.sleaze.dev/classes/Instance.md), `Color`, [`HasTag()`](https://rapi.sleaze.dev/classes/Instance.md) value, or other details.

## Events

### DragContinue

```luau
DragDetector.DragContinue: RBXScriptSignal<(playerWhoDragged: Player, cursorRay: Ray, viewFrame: CFrame, vrInputFrame: CFrame?, isModeSwitchKeyDown: boolean)>
```

- Tags: Capabilities: Input + Physics

Fires when a user continues dragging the object after [`DragStart`](https://rapi.sleaze.dev/classes/DragDetector.md) has been initiated.

### DragContinueReplicate

```luau
DragDetector.DragContinueReplicate: RBXScriptSignal<(playerWhoDragged: Player, cursorRay: Ray, viewFrame: CFrame, vrInputFrame: CFrame?, isModeSwitchKeyDown: boolean)>
```

- Tags: Hidden, Capabilities: Input + Physics

### DragEnd

```luau
DragDetector.DragEnd: RBXScriptSignal<(playerWhoDragged: Player)>
```

- Tags: Capabilities: Input + Physics

Fires when a user stops dragging the object.

### DragEndReplicate

```luau
DragDetector.DragEndReplicate: RBXScriptSignal<(playerWhoDragged: Player)>
```

- Tags: Hidden, Capabilities: Input + Physics

### DragStart

```luau
DragDetector.DragStart: RBXScriptSignal<(playerWhoDragged: Player, cursorRay: Ray, viewFrame: CFrame, hitFrame: CFrame, clickedPart: BasePart, vrInputFrame: CFrame?, isModeSwitchKeyDown: boolean)>
```

- Tags: Capabilities: Input + Physics

Fires when a user starts dragging the object.

### DragStartReplicate

```luau
DragDetector.DragStartReplicate: RBXScriptSignal<(playerWhoDragged: Player, cursorRay: Ray, viewFrame: CFrame, hitFrame: CFrame, clickedPart: BasePart, vrInputFrame: CFrame?, isModeSwitchKeyDown: boolean)>
```

- Tags: Hidden, Capabilities: Input + Physics

### RestartPhysicalDragReplicate

```luau
DragDetector.RestartPhysicalDragReplicate: RBXScriptSignal<(hitPoint: Vector3)>
```

- Tags: Hidden, Capabilities: Input + Physics

## Inherited members

- From [ClickDetector](https://rapi.sleaze.dev/classes/ClickDetector.md): `MaxActivationDistance`, `CursorIcon`, `CursorIconContent`, `MouseActionReplicated`, `MouseClick`, `MouseHoverEnter`, `MouseHoverLeave`, `RightMouseClick`, `mouseClick`
- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
