Get the average volume a player is hearing (in PlaybackLoudness units). This gets all sounds, filters out ones further the set max distance, and averages all the PlaybackVolumes relative to how far away they are from the provided player’s HRP (ones in SoundService are always full volume).
Example Usage
local totalCount = require(script.MainModule)
coroutine.wrap(function()
while wait(0.5) do
print("Average Volume: " .. totalCount(game.Players.LocalPlayer, 5, 35))
end
end)()
Clicky
Roblox Model: AverageVolume - Roblox
Inspired by this post.
If you would like to convert PlaybackLoudness into decibels, refer to this post and this post.