RemoteFunction
Getting Started
On this page you will learn how to properly handle a RemoteFunction from both the client and server side.
Examples
- @Server
- @Client
This will print and return the number generated on the server side.
Methods
RemoteFunction.new() (Constructor)
RemoteFunction.new(name : string)
@Server
Creates a new RemoteFunction wrapper instance for server-side usage
- @param Name: The name of the RemoteFunction to wrap
- @return: New RemoteFunctionComponent instance
- @error: Throws if called from client
@Client
Creates a new RemoteFunction wrapper instance
- @param Name: The name of the RemoteFunction to wrap
- @return: New RemoteFunctionComponent instance
- @error: Throws if called from server or if RemoteFunction not found
RemoteFunction:Handle()
@Server
RemoteFunction:Handle(callback: (Player, T...) -> T...)
Sets the callback function to handle client invocations
- @param callback: Function to execute when invoked by client (includes Player parameter)
- @return: Self for method chaining
@Client
RemoteFunction:Handle(callback: (T...) -> T...)
Sets the callback function to handle server invocations
- @param callback: Function to execute when invoked by server
- @return: Self for method chaining
RemoteFunction:Invoke()
@Server
RemoteFunction:Invoke(Player,... : T...) : any
Invokes the RemoteFunction on a specific client with timeout protection
- @param Player: Target player to invoke the function on
- @param ...: Variable arguments to send to client
- @return: Response from client or nil if timeout
@Client
RemoteFunction:Invoke(... : T...) : any
Invokes the RemoteFunction on the server with timeout protection
- @param ...: Variable arguments to send to server
- @return: Response from server or nil if timeout
RemoteFunction:RemoveHandler()
RemoteFunction:RemoveHandler()
Removes the current handler function
- @return: Self for method chaining
RemoteFunction:SetTimeout()
RemoteFunction:SetTimeout(n : number)
Sets the invocation timeout duration
- @param n: Timeout duration in seconds
- @return: Self for method chaining
RemoteFunction:Destroy()
RemoteFunction:Destroy()
Destroys the RemoteFunction wrapper and cleans up all resources