local g = game.GetService
local r = g(game,"RunService")
local hb = r.Heartbeat
while hb:wait() do
if not script.Parent:FindFirstChild("Sound") then return end
if script.Parent.Sound.PlaybackLoudness > 500 then script.Parent.Sound:Stop(); break end
end
script.Parent.Sound:GetPropertyChangedSignal(“PlaybackLoudness”):Connect(function()
if script.Parent.Sound.PlaybackLoudness > 500 then script.Parent.Sound:Stop() end
end
local sound = //Insert sound location
sound:GetPropertyChangedSignal(“PlaybackLoudness”):Connect(function()
if script.Parent.Sound.PlaybackLoudness > 500 then
sound:Stop()
end
end)
Also, I’d recommend making a message appear on the player’s screen when you stop the audio as some players will get confused on why their audio stopped randomly.
And if you want to limit audio volume, I’m working on a system in my spare time that will allow you to do this.
Note that this property is NotReplicated you’ll have to check the property on the device that started the sound. Also the property doesn’t change when using studio’s sound preview system.
Connect a RunService.Heartbeat connection and check the PlaybackLoudness property.
Also you’ll need to do this on the client.
local RunService = game:GetService('RunService')
RunService.Heartbeat:Connect(function()
if audio.PlaybackLoudness >= 500 and not audio.IsPaused then
audio:Pause()
elseif audio.IsPaused then
audio:Resume()
end
end)
This example would pause the volume if the PlaybackLoudness is 500 or higher until it decreases.