I currently use a single RemoteEvent for pretty much everything to be sent on the server, I just change the first argument (which is a string I call “Code”) depending on what has to be done on the server.
However, I read on another post that using only one is worse as passing even just one more argument can lead to a much higher delay/latency? Is that true, and I should change my method too, or is that false and nothing changes? Thank you in advance!
Edit: Forgot to say, the event is used a LOT and a server can take up to 30 players which can lead to a remote spamming problem.
No, it is worse as it has to send a string argument every time. It’s better to use multiple remote events, especially if you’re going to send them a lot
So, sending as less arguments as possible also make it better? Sorry for the question, but I want to optimize my game as it gets pretty laggy after some time a server is up, especially when the server gets full!
I would say using one is less organized
no idea if it performs better with only one remote event, but I usually only make a new remote event if it is for a different part of the game
A while back I made a Module Script to do this and posted it into #help-and-feedback:code-review, long story short that if you’re looking to narrow your RemoteEvent count it would be better to assign a RemoteEvent per player. The main concern with one RemoteEvent is data limits.
Just personal preference, I’m not a huge fan of how RemoteEvents are object based and was wanting to make them work similar to MessagingService. Also RemoteEvents you can’t trace back which threads are listening for an event easily so I wanted to add a ModuleScript to keep track of listners so at any given time you know what is listening for a certain event.
Really you could just use a RemoteEvent for everything, it just didn’t seem to be the best way to handle adding it with a ModuleScript being part of the loop which I would like to have most of the networking happening through a group of known RemoteEvents.
If you use one remote event, every function connected to that remote will be called when you fire it. Use multiple so you’re only calling the relevant ones.
That isn’t how you would use one remote though. You would ideally have one connection in your server script and one n your client. Then you’d use a buffer and serialize/pack the data/args before sending them through then unpack it on the other end. Then depending on what you send through you call the corresponding module
ive heard that each server has a limit of 50kbs for datasharing for everything, if thats true, it doesnt matter if u have one remote event or many, it will all be queued whenever it goes beyond datasharing limit