RemoteEvent vs RemoteFunction

Question

Why should I use a RemoteFunction if RemoteEvents do basically the exact same thing?

Extra

Just to know I have this right:

RemoteEvent - Replicate stuff to server/client
RemoteFunction - Replicate to server then back to client

1 Like

RemoteFunctions and RemoteEvents are are different for this one key reason:

  • RemoteEvents do not yield the code which calls FireClient, or FireServer.
  • RemoteFunctions, on the other hand, do yield the code which calls either InvokeClient, or InvokeServer because they must wait for whatever values are returned from the connected code.

Basically, if you need the result of some function to be returned use a RemoteFunction. If you do not need the result, but simply need some event to be triggered, use a RemoteEvent. There are also some tricky bugs then can occur if a RemoteFunction is not set up properly. This arctile goes over use cases for both RemoteEvents and RemoteFunctions and also explains the pitfalls you may run into.
Remote Functions and Events (roblox.com)

4 Likes

Oh so RemoteEvents fire the server/client and just keep running the same script whereas RemoteFunctions invoke the server and stop the whole script until the script it was called on is complete?

Almost… Neither RemoteEvents nor RemoteFunctions have the ability to start scripts, instead they start functions. Replace “script” with “function” or “thread” in your reply and that’s closer to a correct idea of what’s going on.

1 Like