Is using a single RemoteEvent better than using multiple ones?

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.

1 Like

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

2 Likes

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!

2 Likes

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

I do this to make it organized

1 Like

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.

1 Like

isn’t that more remote events depending on how many players there are?
what is the point of this?

1 Like

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.

1 Like

Yeah passing less data through the event can help saving resources though the difference is usually small

1 Like

If you use one then you get the problem of Performance.

I think it is quite neat and tidy just to use one RE however you would need to pass in the Code and the extra parameter data if there is any.

Remote events can only be fired for a certain amount of times before it is blocked by the server to prevent RE spamming as you s too.

You also have to perform those checks on the server with if statements which does impact performance too.

Now I usually put all the logic on the client and have a bunch of different events reserve the server for AntiExploits and Server required methods.

1 Like

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.

1 Like