Playbackloudness on a part

So recently, I have been trying to make a script that detects the sound level around a rig, I tried using playbackloudness on the client but it returns the sound level around the player. How would I be able to check the loudness level of a sound from a part in a rig?

local soundPart = workspace:WaitForChild(“SoundSource”) – The part emitting sound
local rig = workspace:WaitForChild(“Rig”) – The character detecting the sound

local sound = soundPart:FindFirstChildOfClass(“Sound”)
if not sound then return end

local function getSoundIntensityAtPosition(source, listener, baseLoudness)
local distance = (source.Position - listener.Position).Magnitude
if distance < 1 then distance = 1 end – Avoid division by zero

-- Inverse Square Law: Intensity ∝ 1 / (distance^2)
local adjustedLoudness = baseLoudness / (distance^2)
return math.clamp(adjustedLoudness, 0, 1000) -- Clamp between 0 and 1000

end

while true do
local playbackLoudness = sound.PlaybackLoudness
local estimatedLoudness = getSoundIntensityAtPosition(soundPart, rig.PrimaryPart, playbackLoudness)

print("Estimated Loudness at Rig:", estimatedLoudness)

task.wait(0.1) -- Adjust frequency of updates

end

It still only prints the playbackloudness of the player’s client, I need it to play from the rigs pov

local soundPart = workspace:WaitForChild(“SoundSource”)
local rig = workspace:WaitForChild(“Rig”)

local sound = soundPart:FindFirstChildOfClass(“Sound”)
if not sound then return end

local function getSoundIntensityAtPosition(source, listener, baseLoudness)
local distance = (source.Position - listener.Position).Magnitude
if distance < 1 then
distance = 1
end
local adjustedLoudness = baseLoudness / (distance^2)
return math.clamp(adjustedLoudness, 0, 1000)
end

while true do
local playbackLoudness = sound.PlaybackLoudness
local estimatedLoudness = getSoundIntensityAtPosition(soundPart, rig.PrimaryPart, playbackLoudness)
print(“Estimated Loudness at Rig’s POV:”, estimatedLoudness)
task.wait(0.1)
end

It still doesn’t print out the loudness from the rig, the script is a client runcontext script thats inside the rig.

Hey nothing about your script is wrong but on the fourm we put code in three ticks ``` then we close them with three ticks. It just makes the code easier to read and it formats it correctly.

Hi everybody, I have made my own script that detects the loudness of sounds so yea.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.