I made this script to make a speaker vibrate when a loud sound is played. It works in studio but not in game. The PlaybackLoudness is constantly printing 0 in game.
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local One = script.Parent.Parent.Woof1
local Two = script.Parent.Parent.Woof2
local Sound = script.Parent.ClubMusic
local PrevVol = Sound.PlaybackLoudness
local Info = TweenInfo.new(
.1,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out,
0,
true,
0
)
local Goal = {}
Goal.Size = Vector3.new(0.125, 1.75, 1.75)
local Tween1 = TS:Create(One, Info, Goal)
local Tween2 = TS:Create(Two, Info, Goal)
RS.Heartbeat:Connect(function()
print(Sound.PlaybackLoudness)
if Sound.PlaybackLoudness - PrevVol > 200 then
Tween1:Play()
Tween2:Play()
end
PrevVol = Sound.PlaybackLoudness
end)