Hi guys, basically im making a shooter game and ive had this issue for a long time, but its time to fix it.
Ok so, I have a shooting sound right? It plays when i shoot my gun. I want other people to hear it. In order to do that, i use a remote event, that makes the server play the sound. This works fine, but if i have ping above 30 or so, it becomes very noticably delayed compared to all the other VFX and stuff that im handling on the client. Is there a way to play the sound with 0 delay for the shooter, and also have it be heard by other people???
You could use an UnreliableRemoteEvent in place of a RemoteEvent.
Play sound on client
Fire remote
Server creates sound
Server fires remote back to player that shot
Client deletes sound so the player doesn’t hear it but others do
This method might be more expensive but it’s the simpiliest way to explain it.
The OP wants other players to hear it, and it’s using a very similar method to yours.
I’ll try to explain it better,
basically, the client that fired the gun will hear their gun sound. Then, the client tells the server “I’ve shot” and the server then plays a firing sound, but it tells the client that shot not to play that sound. When you do it that way, there’s not a duplicate sound for the client that fired the gun, but everybody else will still hear the firing sound.
The more complex but optimized method is to play the sound on the client that shot, tell the server “I’ve shot” then have the server fire a remote to all other clients except the shooter to play the shoot sound.
The op also worded it a bit odd so I couldn’t fulkly understand but I think he is only playing the fire sound on the server because then there’d be no delay.
An UnreliableRemoteEvent could be used in place of a RemoteEvent to lower the latency.
They do not have lower latency. The latency is exactly the same. The difference is—the unreliable remote event is unordered and can drop network packets.
They do not solve OP’s problem.
There are many approaches to solving this issue. But a common one is:
- Play the sound immediately on the client that is firing the gun
- Fire an event to the server
- Server then fires the sound event to every other client (meaning everyone but the person who shot it)
- Other clients receive the event and play the sound
The Sound object needs to be parented to a part that is in the Workspace (like a gun model the player is holding in your case). Then a ServerScript plays the sound, or a ModuleScript called from a ServerScript. SoundService is the alternative for non-positional audio (like music).
This is how I do that anyways.. No RemoteEvents needed, Built-in 3D positioning and Automatically synced.
Yeah that might just be the most reliable solution, because @RuinedSanctuary 's solution is still affected by latency. Thanks a lot for responding
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
