Hello,
So I have a module script that controls gui effects. It also includes a function that plays a haptic on supported devices. However, I published the game to a group and now the haptic effect doesn’t work. Here is the script, it is exactly the same in the group game and my private one:
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local HapticService = game:GetService("HapticService")
local ButtonModule = {}
-- Function to play a sound
local function playSound(sound)
SoundService:PlayLocalSound(SoundService:WaitForChild(sound))
end
-- Function to play haptic feedback
local function playHaptic()
if HapticService:IsVibrationSupported(Enum.UserInputType.Gamepad1) then
HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, 0.8)
task.wait(0.05)
print("HapticComplete")
HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, 0)
end
end
function ButtonModule.SetupButton(button)
print(button.Name)
if button:FindFirstChild("Pet") then
local viewportFrame = button:FindFirstChild("Pet")
if viewportFrame:IsA("ViewportFrame") then
local originalScale = viewportFrame.Size
local hoverScale = UDim2.new(originalScale.X.Scale * 1.08, 0,originalScale.Y.Scale * 1.08 ,0 )
local pressScale = UDim2.new(originalScale.X.Scale * 0.92,0,originalScale.Y.Scale * 0.92,0)
local function scaleViewportFrame(size)
local tweenInfo = TweenInfo.new(0.07, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local properties = {Size = size}
local tween = TweenService:Create(viewportFrame, tweenInfo, properties)
tween:Play()
end
button.MouseEnter:Connect(function()
scaleViewportFrame(hoverScale)
playSound("click2")
end)
button.MouseLeave:Connect(function()
scaleViewportFrame(originalScale)
end)
button.MouseButton1Down:Connect(function()
scaleViewportFrame(pressScale)
playHaptic()
end)
button.MouseButton1Up:Connect(function()
scaleViewportFrame(hoverScale)
playSound("click2")
end)
end
else
local size = UDim2.new(button.Size.Width.Scale, 0, button.Size.Height.Scale, 0)
button.MouseEnter:Connect(function()
button:TweenSize(UDim2.new(size.X.Scale * 1.04, 0, size.Y.Scale * 1.04, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.06, true)
playSound("click2")
end)
button.MouseLeave:Connect(function()
button:TweenSize(size, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.06, true)
end)
button.MouseButton1Down:Connect(function()
button:TweenSize(UDim2.new(size.X.Scale * 0.96, 0, size.Y.Scale * 0.96, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.06, true)
playHaptic()
end)
button.MouseButton1Up:Connect(function()
button:TweenSize(UDim2.new(size.X.Scale * 1.04, 0, size.Y.Scale * 1.04, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.06, true)
playSound("click2")
end)
end
end
return ButtonModule
It prints the “HapticComplete” in both games.
Could there be some setting I need to enable?