I've heard that remotefunctions are faster than remoteevents. Since remotefunctions can do everything remoteeevents can do, what is the purpose of remoteevents? I was looking at a GUI catalog and they use remotefunctions instead of remoteevents.
Which should be used when?
RemoteFunctions are designed for two way communication, while RemoteEvents are designed for one way. A RemoteFunction sends a request and then waits for a response, while RemoteEvents just send a request.
Another difference is how they are handled, RemoteEvents use the Roblox event systems, something like FireServer()
or OnServerEvent
. RemoteFunctions use a callback. For every RemoteFunction, only one callback can be defined on the server and only one for each client.
The last difference is how many different targets remote events and functions can have. For both RemoteEvents and RemoteFunctions, a client can contact the server and the server can contact the client. In the case of RemoteEvents, the server can also contact every client at the same time.
With this information you can decide what and where you use them. As I said before, the main difference is that RemoteFunctions waits a response. I hope I helped!