Sound attenuation for local sounds

The dev api says this about sounds … " A sound placed in a BasePart or an Attachment will emit its sound from that part’s BasePart.Position or the attachment’s Attachment.WorldPosition … A sound is considered “global” if it is not parented to a BasePart or an Attachment . In this case, the sound will play at the same volume throughout the entire place."

From that text above, it sounds as though all I need to do is make sure my sound is placed in a basepart or attachment. However I need my sounds to be local, and only audible to a certain client, that is within range of the sound, so I noticed the following text…

" Sound playback is not filtered. If a particular client starts playing a sound, all of the other clients will also play it unless SoundService.RespectFilteringEnabled is set to true."

So I set SoundService.RespectFilteringEnabled to be true
Then I read …

" While the playback of sounds will replicate, other properties such as the playback speed, pitch, volume, etc. will not replicate. This behavior can be avoided by creating all sounds locally on the client, as instancing sounds will not replicate to the server."

So I made sure my models on the client had their sound object be instanced from a local script

However, when I tested, there was no sound attenuation, it was at a global volume level.

Then I saw this…

" Sounds parented to a BasePart or Attachment that are descendants of the Workspace are considered 3D sounds and their volume whilst playing is dependent on the distance between the client’s sound listener"

So I noticed it says “Workspace” even though my sound objects are parented to baseparts in the ‘local workspace’ (parented to workspace with FE true) it still is at a global sound level, so this makes me think when the text says “Workspace” they really mean “Server Side Workspace”

I would like to also note that I tried to create the sound in Player.Character, and CurrentCamera and still the same results

So, before I try to write for find some sound code (because I would rather use the Roblox one with attenuation and doppler) I decided to ask and see if anyone has been able to get the sounds attenuation (EmmiterSize and MaxDistance) to work from a basepart that is located on the client.

Thank you for your time.

First of all, you made these sounds on the client and they’re parented to baseparts and/or attachments right?

Second, if that is the case and your sounds still seem off, there’s currently a sound glitch on Windows machines: World/stereo sounds appear to have broken since yesterday's update

Are you using Windows 10? If so, do you have any other devices you can use to test the sounds?

SoundService has a method especially made for playing sounds locally: PlayLocalSound. Maybe you could pair that with instancing the sounds on the server if that fixes your problem.

Correct, the sounds are created locally from a local script, and added as children to local baseparts.
The sound doesn’t seem off as much as its acting like a global un-parented sound, in that there is no falloff of volume as you move away from it.

Thanks for the suggestion, but it still has the same result as an un-parented sound.

1 Like

PlayLocalSound honestly has no business showing itself in a production environment. There are very rare cases that you’ll actually need it. It’s really only good for testing or plugins.

The thing is that sounds played using this method are treated as global sounds and they completely cut out the majority of functionality from using a raw Sound object.

1 Like