PlayOnRemove doesn't respect max distance

Sounds which have PlayOnRemove enabled do not respect the MaxDistance property upon removal.

Reproduced on an empty baseplate:

14 Likes

8 months later and they still have not fixed this bug.

5 Likes

Ran into this bug very recently. Extremely confusing and not intuitive. I was able to hear my sounds from across the map no matter what I set the ranges to. Took me several hours before I realized what was causing it.

5 Likes

I can reproduce this issue

Does anyone know of a workaround?

Wrap your code with coroutine or spawn and wait for the audio to finish playing (I like to use Debris:AddItem(instance, time) time would be the length of the audio)

If due to lag or time taken loading the sound file the sound starts at a delay then the sound will abruptly stop

If that’s important you could just wait for the IsLoaded property of Sound. If you want a bit of overhead, you could also add a few milliseconds onto the time before the sound is destroyed.

Preloading the asset will surely fix the issue

How exactly does preloading work? I tried PreloadAsync and it did nothing

Correct me if I am wrong:
As it says, its meant for preloading assets, so they won’t load when it first shows up. A sound that plays for the first time, first loads and then play it after. Somehow it just cuts the audio right off, so I doesn’t even manage to finish playing. (Happens to short audios I believe).

This can be avoided with, as you say PreloadAsync. It preloads the assets, and doesn’t have to be loaded again by the client which won’t cause any playing issues when first played.

Hey all; this should be addressed now; Sound.PlayOnRemove and SoundService:PlayLocalSound now take RollOffMaxDistance into account

5 Likes

Thank you! Good to see these old issues getting worked through steadily :slight_smile:

2 Likes

This one was actually fixed some time ago; didn’t see this thread or I would’ve replied sooner!

PlayOnRemove has historically been a bit buggy, since it potentially plays the Sound after it has been destroyed :sweat_smile:

There are various quirks, like Sounds that are triggered via PlayOnRemove don’t loop (if they did, you’d have no way to stop the looping!) – generally, Playing and Stopping sounds directly has more predictable, stable behavior, but we recognize that the PlayOnRemove property is quite popular

1 Like

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