I tested out Sound.RollOffMode and its audio volume difference isn’t noticeable with increasing/decreasing distance. How do i make it so that the different in volume is noticeable with increasing/decreasing distance, preferably in a linear way
btw I tried Linear mode and the difference still isnt noticeable
You have to set the RollOffMinDistance and RollOffMaxDistance to the number of studs away from the Part or Attachement the Sound is in.
If you have the sound anywhere else it’s considered a Global sound and will be heard everywhere in the game.
For the RollOffMode I prefer InverseTapered.
Inverse just cuts off abruptly.
Linear isn’t very realistic to me.
In real life sound decreases according to the inverse squared formula.
When you double the distance from the source the intensity of sound decreases by 4 (2 squared) times. If you triple the distance, sound intensity decreases by 9 times (3 squared).
local function PlaySound(playedSound, config, weapon)
playedSound.RollOffMaxDistance = config:GetAttribute("SoundRange")
playedSound.RollOffMode = Enum.RollOffMode.InverseTapered
if config:GetAttribute("SoundRange") * 0.2 < 10 then
playedSound.RollOffMinDistance = 10
else
playedSound.RollOffMinDistance = config:GetAttribute("SoundRange") * 0.2
end
local playerRootPart = weapon.Parent.HumanoidRootPart
playedSound.Parent = playerRootPart
-- Playing the sound and animation and then destroying it
for _, otherPlr in Teams.Playing:GetPlayers() do
local distanceToPlayer = (otherPlr.Character.HumanoidRootPart.Position - playerRootPart.Position).Magnitude
-- Sound is played on client if it's within range
if distanceToPlayer < config:GetAttribute("SoundRange") then
PlayEffect:FireClient(otherPlr, "Sound", playedSound)
end
end
end