Make only specific sounds RespectFilteringEnabled?

I have a hitmarker sound effect that I need to only play on the client. The sound is just in workspace with emitter size 99999. Can I make the sound only play on the client? It is triggered by a localscript

No. I don’t see why you’d want to do this. Use remote functions and events.

Sorry I edited and clarified the question a bit

Put the sound in workspace.CurrentCamera on the client, that should stop it from replicating

SoundService.RespectFilteringEnabled should be enabled, otherwise you’re leaving a huge vulnerability that allows malicious users to play any sound to every player; this should not be an issue is the first place. Have the client signal the server using remote functions and events to replicate any sounds you feel necessary (with proper verification).

2 Likes

If you keep the sound in PlayerGui or CurrentCamera, the sound should only play for the client that it’s under.

You cannot whitelist specific sounds to abide by RespectFilteringEnabled and I don’t know why you would ever want to either. You should be using RespectFilteringEnabled by default, because sound playback will replicate otherwise and you open yourself up to a world of annoying exploits.

Seems more like an XY problem. What you should’ve asked is how to make only one client hear a sound, not how to “make specific sounds respect FilteringEnabled”. Just turn on RespectFilteringEnabled and play the sound, it’s that simple. As for your other sounds, get remotes in and use proper validation to prevent exploiters from firing said remotes (i.e. do not make a remote with only a sound argument and “sound:Play()” as the code).

I’m not really sure why you’re putting the hitmarker sound in the Workspace to begin with, while putting it’s EmitterSize to 9x105. If it was to make it play from a certain world point I’d understand, but this seems like a bad version of just putting the sound in, say, PlayerGui, or whatever.

Last thing - SoundService.PlayLocalSound also exists. Check the Developer Hub for information.

2 Likes

You could just create the sound on the client, and play it from there.

2 Likes