What's faster? Networking question

Hello!

I have a combat system, with sounds ofc, and I wanted to know which is faster

Remote events or creating the sound on the server

Here’s how it would go if it’s remote events:
Client fires to the server to replicate/create an attack sound
Server fires all clients but that one to play this sound
Other clients receive and play it if they’re close enough

How it works with creating the sound on the server, and what I currently have
Client fired to the server to replicate/create an attack sound
Server creates it and parents it to the player

Which is faster?
I would prefer the remote event method if it’s okay, because the client that’s making the sound will have no delay, but will it increase the delay for others? I’m not sure if it replicates faster than a remote event can fire

To note, all other sounds are client sided via animations, but this specific one is if they hit someone, which I can’t calculate from other clients

1 Like

I would recommend having all sounds parented to any part in players character, thats totally upto you. This is because, roblox already has a sound system, if you are too far away from the sounds parent thats a BasePart, then it adjusts the volume for you depending on how far.

I don’t see any other way than using remote events to play the sound, just play it on server. For hit sounds, you can play them using the same script you use to damage the target player thats hit.

1 Like

So, client fires to server, server plays the sound, as simple as it is.
I do not recommend dealing with fireallclients cause you know, playing just a sound on server shouldn’t be something laggy. And if you do fireallclients, you’d then have to deal with sounds returning nil if the character isnt in the player streaming radius or whatever. So yeah I do not recommend fireallclients.

1 Like

I would think anything already in place would be faster than any other way.
Myself I would put the sounds inside of where ever they need to be projected from and play them when needed. As simply stating play() would be faster that any create the sound then play() method. This also covers any need to calculate sound distance hearing. Cutting even more off what is needed to just play a sound.

I may be way off here, but it sounds like you’re over complicating something simply done.

1 Like

You can really use Debris Service, to create a Sound Instance, play it and it gets removed. But I do not understand the point, doing this might make it seem like its an optimized way but it really isn’t, the sound instances already being there is the best way in my opinion. Creating a new sound instance might sometimes also lead to sound failing to load quickly problems and all that.

1 Like

My “system” fires the client to make the sound on their client, it will do things like making sure that entity isnt nil, distance checks, etc.

My main purpose of this is so the client that attacked wont have a delay in their sound, because they have to wait for it to replicate, and if I make it play locally and on the server, theyll hear it twice.

1 Like

I’m not really going to store every single sound a player can use in their character everytime they spawn

This is nothing complex, most of my things for other entities such as vfx, sounds, etc are all local, and they simply wont create a sound if the player is say 100 studs out.

As for volume, I just use roblox’s built in feature, simply asking if it would be faster to replicate if the server creates and plays the sound or if firing a remote for the client to create the sound.

The main reason for this is so the client that attacked doesnt have a delay in when they hear the sound, but if it creates a larger delay and is overall worse for other clients, I just will leave it to the server to create it.

I may not be wording this right or just making it sound very confusing, which im very sorry for, but im not overcomplicating anything really…

1 Like

Hm, I’ve been just using a connection to .Ended, but debris may be better.

This isnt really an optimizing thing, its that I control all sounds on the client already, so I’d like to keep it that way if it isnt going to cause problems. And the player attacking wont have a delay in the sound because of network delay

1 Like

Hello, if you want to optimize remotes you can check out this amazing networking library called BridgeNet2.

Rbxm file: BridgeNet2-v1.0.0.rbxm (29.8 KB)
(Or you can download through wally if you use it)

Doc: BridgeNet2 | BridgeNet2

1 Like

I believe all VFX, sounds, etc should be play on the client rather than the server. For example in my gun system, the client firing the gun will do visuals on their client and then send an event to the server. The server then sends the event back to all the clients except that one and those separate clients play the effects.

This will result in smoother effects and less stress on the server, the only downside to this system is by the time it takes to fire a remote, then redirect it back to all the clients, the player that was shot might of moved a few studs.

1 Like

Already using this for my networking! :smiley:

1 Like

The remote event method can offer a good balance between minimal delay, all things considered.

2 Likes