Resource
SafeInvoke - Creator Store (roblox.com)
I made this module for managing my remote functions without deviating too much from Roblox’s vanilla remote functions. The only two things I added was timeout, and an error handler. I still do not know why Roblox has not added these yet but here I am making this module for my project. If there are any areas that could be improved, please do tell me in the replies. This is assuming that you already know how to use Remote Functions. Although, there are other resources out there that are much better than mine, I just wanted to share this just in-case anybody finds it useful.
Usage
If you already have a remote function variable then just wrap it with SafeInvoke.new()
local SafeInvoke = require(SafeInvoke)
local remoteFunc = SafeInvoke.new(ReplicatedStorage.Events.RemoteFunction)
We can still hook a function to the OnServerInvoke or OnClientInvoke like how you would normally would.
remoteFunc.OnServerInvoke = function() end
remoteFunc.OnClientInvoke = function() end
There are two ways you can use this module to invoke.
- Using our variable reference.
local remoteFunc = SafeInvoke.new(RemoteFunction)
remoteFunc:InvokeServer()
remoteFunc:InvokeClient()
- By calling
new
and directly calling invoke.
SafeInvoke.new(RemoteFunction):InvokeServer()
SafeInvoke.new(RemoteFunction):InvokeClient()