What would be the best way to play audio on both client and server without client hearing double?

So I want to play a gun fire audio clip and for the user to not experience a latency, I want to play the audio locally and the trigger the server to play the same audio clip to every other client except the original client.

I am currently using RemoteEvent to do this but if I’m firing a gun which has a fire rate, I think this method might be using up the bandwidth too much.

Any suggestions? Thanks in advance!~

1 Like

You could immediately fire the RemoteEvent again for all clients, and then all the clients would then play it locally too. The trick is to make sure to pass the original player as an argument too, so that the original player avoids playing it twice.

8 Likes

You can, instead of using sound:Play() on the server, instead fire a RemoteEvent with the sound as an argument to all clients except the player who fired the gun to play the sound.

2 Likes

Just put the sound in a part inside the character of the client and call :Play() on it whenever you want to play the sound. There won’t be any delay for the player and everyone else will hear it too.

2 Likes

As much as I want to use this method, problem is that lets say that my gun fires a huge amount of shots per second. That would be too much data sending between networks.

This doesn’t work with latency which he doesn’t want.

Yeah, basically, I want the client to hear the audio play without latency to give 0 ping illusion effect while the other clients hearing it a little late is fine.

Have all sounds for guns connected to a SoundGroup for each player. In a LocalScript, mute the LocalPlayer’s respective SoundGroup. Play the client sounds not with the SoundGroup. Play the server sounds in the SoundGroup.

1 Like

??? I don’t understand, doing :Play() on the sound which is in your character would play immediately on the client and it would also play for other clients.

1 Like

Only if RespectFilteringEnabled isn’t enabled (which it should be should you risk exploiters spamming every sound very annoyingly).

2 Likes

That’s not a big problem, I’ve never had RespectFilteringEnabled in any of my games and never ran into anyone spamming sounds like that, nor got any complaints about anyone doing that.

There are scripts everywhere on it, and they’re extremely short. Just because nobody has done it to your game doesn’t mean it’s not an issue when it happens. Keep it safe, just use RespectFilteringEnabled.

5 Likes

By playing the sound on the server, you’re still sending the same amount of data to every client, just in a different way. If you play the sounds locally using the RemoteEvent method, it should be perfectly fine!

1 Like

Doing Sound:Play() will play the sound globally if you don’t have RespectFE on like that dude said, don’t worry about exploiters they can’t do much with Sound anyways.

1 Like

Exactly, spamming sound is a pretty insignificant exploit so I’d just do it the easier way without worrying about remote events.

I finally decided on playing them through remotes either way as the sound has to be cloned by the client so I no matter RespectFilteringEnabled on or off, I have to go through remotes.

Thanks for everyone’s help.

3 Likes

You need to display something for all other clients when the gun fires anyway. Just include playing the sound in this to minimize requests.

2 Likes