How careful do I need to be with RemoteEvents?

Hi all. I’m currently writing a script for processing and displaying NPC dialogue. I store the dialogue data on an NPC, then when I activate the ProximityPrompt, it fires a table filled with all the dialogue contained in that NPC over to a localscript under StarterPlayerScripts using a RemoteEvent. It reads it, then constructs and handles the rest of the process locally.

My friend who I’m working with, insists that using a RemoteEvent is wasteful here. She’s said that it’s important to be incredibly cautious with using RemoteEvents for only essential tasks, which I do agree with, but I feel like my usage here is justified. Without using RemoteEvents, I don’t feel like I can think of a reasonable solution to making this script (not any method that would be any more efficient anyways), so I need a clear answer as to whether she’s justified in saying that I shouldn’t be using a RemoteEvent here, or that I’m completely fine to use it.

1 Like

Could you not handle this fully client sided? Store and process the dialog on the client and then also display it on the client.

I think getting the server involved in this situation is wasteful. I would avoid the RemoteEvent.

In that scenario you can handle it fully on the local side, and then just signal the dialogue progress/outcome to the server with RemoteEvents.

For example you have 3 branches of the dialogue, that conclude in different outcomes. Depending on choices the player made, at the end of the dialogue - you fire the server with the specific outcome the player, like:

DialogueRemote:FireServer("SomeDialogue", "OutcomeA")

This way you just process the dialogue and the whole interaction on the client and save resources on unneeded replication, while only telling the server that a specific action concluded in a certain way.

To make sure it’s not abusable with just remote firing using exploits - you add server side checks, making sure that the player is actually able to process a certain dialogue outcome.

Hope that helps!

1 Like

If this has no affiliation with network replication, it isn’t optimal to use Remote Events as it’s inefficient and causes network lag. You would rather conduct all locally.

I suggest UnreliableRemoteEvent if you really do need a remote event.

No, you never need Remote Event in such cases. You need to use Remote Event only when there is need for sending information from server to client or vice-versa.

You say that dialogue data “is stored on an NPC”, I don’t really understand what does it mean, but if it’s some instances under NPC or some attributes, they are already visible on client, so you don’t need to send this info again from server to client.

As alternative, you can just create a ModuleScript that has all information about your dialog and put it inside of ReplicatedStorage so client can access it. This way as soon as client loaded, it will already have all dialogs.

Then when prompt is triggered, play dialog, also locally. If your answers should be saved, yes, send them to server via Remote Event.

1 Like

If the remote event is not connected to a serverscript by “.OnServerEvent”, then you’re alright. The reason why people say you gotta be cautious is because people with executors (exploits) can repeatedly fire the remote event which will cause server lag, but only if atleast one serverscript has the “.OnServerEvent”.