Class
HapticService
NotCreatableServiceNotReplicatedDeprecated
Provides haptic feedback to controllers and devices.
Deprecated. This service has been superseded by HapticEffect, a newer instance
that supports multiple haptic effect types, looped effects, and customizable
haptics.
HapticService allows scripts to query vibration support and set motor
intensities on gamepad controllers, VR controllers, and mobile devices. Use
IsVibrationSupported() and
IsMotorSupported() to check device
capabilities, then SetMotor() to drive a
specific VibrationMotor on a given UserInputType. Motor output
is scaled by the user's haptic intensity preference in their Roblox settings.
As this service is client-side only, it can only be used in a
LocalScript, a ModuleScript required by a LocalScript,
or a Script with RunContext set to
RunContext.Client.
This service has been superseded by HapticEffect, which supports
waveform-based effects, looping, spatial attenuation, and preset effect types.
For new work, use HapticEffect instead.
Methods 4#
| GetMotor | Returns the current vibration value set to the specified
UserInputType and VibrationMotor. |
| IsMotorSupported | Returns true if the specified motor is available to be used with the
specified UserInputType. |
| IsVibrationSupported | Returns true if the specified UserInputType supports haptic
feedback. |
| SetMotor | Sets the vibration intensity of the specified
UserInputType and VibrationMotor. |
GetMotor(inputType: UserInputType, vibrationMotor: VibrationMotor): Tuple#
Returns the current vibration value set to the specified
UserInputType and VibrationMotor.
This will not return anything if
SetMotor() has not been called prior.
| Name | Type | Default | Description |
|---|---|---|---|
inputType | UserInputType | The specified UserInputType. | |
vibrationMotor | VibrationMotor | The specified VibrationMotor. |
Returns
Tuple— The current vibration value set to the specifiedUserInputTypeandVibrationMotorornilifSetMotor()has not been called prior.
IsMotorSupported(inputType: UserInputType, vibrationMotor: VibrationMotor): boolean#
Returns true if the specified motor is available to be used with the
specified UserInputType.
| Name | Type | Default | Description |
|---|---|---|---|
inputType | UserInputType | The specific UserInputType being checked for
VibrationMotor support. | |
vibrationMotor | VibrationMotor | The specified VibrationMotor checked to see if it supports the
specified UserInputType. |
Returns
boolean— Boolean oftrueif the specified motor is available to be used with the specifiedUserInputType,falseif not.
IsVibrationSupported(inputType: UserInputType): boolean#
Returns true if the specified UserInputType supports haptic
feedback.
| Name | Type | Default | Description |
|---|---|---|---|
inputType | UserInputType | The specified UserInputType checked to see if it supports
haptic feedback. |
Returns
boolean— Boolean oftrueif the specifiedUserInputTypesupports haptic feedback.
SetMotor(inputType: UserInputType, vibrationMotor: VibrationMotor, vibrationValues: Tuple): ()#
Sets the vibration intensity of the specified inputType and
vibrationMotor. Note that almost all usage cases specify
UserInputType.Gamepad1 for inputType which is internally mapped
to the device's respective hardware.
| Name | Type | Default | Description |
|---|---|---|---|
inputType | UserInputType | The specified UserInputType. | |
vibrationMotor | VibrationMotor | The specified VibrationMotor. | |
vibrationValues | Tuple | How intensely the motor should vibrate. Only uses the first value in the tuple, which should be a number. |
Returns
()
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild