As @colbert2677 covered most of it already you might want to also look into CompressorSoundEffect as it works as a normalizer to keep a consistent volume level all the time for any sound.
If you’re absolutely set on the PlaybackLoudness for other uses as well you can try this out for a more consistent result:
local RunService = game:GetService("RunService")
local SoundService = game:GetService("SoundService")
local function MaxPlaybackLoudness(soundId, scrubTime, scanAmount)
local ListPlaybackLoudness = {}
local MaxPlaybackLoudness = 0
local ScanSection = 0
local ScanFinished = false
local Sound = Instance.new("Sound")
Sound.Parent = game.SoundService
Sound.SoundId = soundId
repeat RunService.Stepped:Wait() until Sound.IsLoaded
print("Scrubbing soundId:", Sound.SoundId)
local startTime = tick()
for soundTime = 0, Sound.TimeLength, scanAmount do
ScanSection = ScanSection + 1
spawn(function()
local scrubSound = Sound:Clone()
local startScrub = tick()
scrubSound.Parent = game.SoundService
scrubSound.Volume = 0
scrubSound:Play()
scrubSound.TimePosition = soundTime
local ScrubStep = RunService.Stepped:Connect(function()
table.insert(ListPlaybackLoudness, scrubSound.PlaybackLoudness)
end)
repeat RunService.Stepped:Wait()
until (tick()-startScrub) > scrubTime
ScrubStep:Disconnect()
scrubSound:Stop()
scrubSound:Destroy()
scrubSound = nil
if ScanSection >= soundTime then
ScanFinished = true
end
end)
end
repeat RunService.Stepped:Wait() until ScanFinished
Sound:Destroy()
Sound = nil
print("Completed scrubbing:", tick()-startTime)
print("Peak audio loudness:", math.max(unpack(ListPlaybackLoudness)))
end
--[[MaxPlaybackLoudness
soundId: audio id to fetch
scrubTime: amount of seconds to record pbl for sound instance
scanAmount: amount of seconds to create sound instance
]]--
MaxPlaybackLoudness("rbxassetid://203626633", 2, 2)