HapticEffect

Show Deprecated
Not Browsable

Modern controllers and devices have motors built‑in to provide haptic feedback. Adding rumbles and vibrations can provide subtle feedback that is hard to convey through visuals or audio.

Roblox supports haptics for the following devices:

  • Android and iOS phones supporting haptics including most iPhone, Pixel, and Samsung Galaxy devices
  • PlayStation gamepads
  • Xbox gamepads
  • Quest Touch controller

Summary

Properties

Methods

  • Play():()

    Plays the haptic effect.

  • Method used to define a custom waveform as a table and apply it to the haptic.

  • Stop():()

    Stops the haptic effect.

Properties

Looped

Read Parallel

Whether the haptic effect loops continuously.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Looped = true
effect.Parent = Workspace
-- Start the haptic effect
effect:Play()
-- After two seconds, stop the effect
task.wait(2)
effect:Stop()

Position

Read Parallel

Along with Radius, specifies the impact position relative to the input device and, effectively, how broadly that impact effects nearby motors. Note that some gamepads do not have both "small" and "large" motors, and that "gamepad large left/right" is not supported on PC.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set the position and radius of impact
effect.Position = Vector3.new(0.5, 0.5, 0)
effect.Radius = 1
effect.Parent = Workspace
effect:Play()

Radius

Read Parallel

Along with Position, specifies the impact radius relative to the input device and, effectively, how broadly that impact effects nearby motors. Note that some gamepads do not have both "small" and "large" motors, and that "gamepad large left/right" is not supported on PC.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set the position and radius of impact
effect.Position = Vector3.new(0.5, 0.5, 0)
effect.Radius = 1
effect.Parent = Workspace
-- Play the haptic effect
effect:Play()
Read Parallel

The haptic type, such as Enum.HapticEffectType.GameplayCollision for a large immediate rumble that dies down quickly. The Enum.HapticEffectType.Custom value lets you specify a haptic with custom waveform keys defined through SetWaveformKeys().

Waveform

Roblox Script Security
Read Parallel

Methods

Play

()

Plays the haptic effect.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Parent = Workspace
-- Play the haptic effect
effect:Play()

Returns

()

SetWaveformKeys

()

This method lets you define a custom waveform as a table and apply it to the haptic.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set effect type to custom in order to define a waveform
effect.Type = Enum.HapticEffectType.Custom
effect.Parent = Workspace
-- Define the custom waveform curve through a table
local rampUpWaveform = {
FloatCurveKey.new(0, 0.3),
FloatCurveKey.new(100, 0.4),
FloatCurveKey.new(300, 0.8),
FloatCurveKey.new(400, 1.0)
}
-- Set waveform through the effect's method
effect:SetWaveformKeys(rampUpWaveform)

Parameters

keys: Array

Returns

()

Stop

()

Stops the haptic effect.


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Looped = true
effect.Parent = Workspace
-- Start the haptic effect
effect:Play()
-- After two seconds, stop the effect
task.wait(2)
effect:Stop()

Returns

()

Events