Network Functions
Last updated
Last updated
Network Functions allow for two-way client to server communication and follow a request and response format.
An example of when a RemoteFunction
would be appropriate is a player requesting to open a loot crate. First the player tells the server the kind of crate it would like to open, and the server responds with what the player received.
Purchase Request
Client requests to purchase an item, server validates the transaction, client is notified of the result
Firing a Network Function on the client
Listening to Network Functions on the server
Network Functions that originate on the server behave exactly the same.
Like , Network Functions can be created inside of any script. A NetworkFunction
expects two generic parameters: a request type and response type.
SetCallback
's first parameter is always the who fired the network function.
NetworkFunctions
are synchronous, the active thread will yield until the callback returns. Consider wrapping FireServer
and FireClient
calls inside of to avoid interfering with the flow of your game.