Skip to content

Invoking Packet Functions

Packet Functions return a Promise when invoked.

This allows the caller to asynchronously wait for the response without blocking execution.

Server-owned functions are invoked from the client.

Example:

Network.Server.RequestData:Invoke(nil, {
id = 123
}):andThen(function(result)
print(result.name)
print(result.score)
end)

The Promise resolves when the server callback returns a value.

Client-owned functions are invoked from the server.

Example:

Network.Client.GetPing:Invoke(player):andThen(function(ping)
print(ping)
end)

Since PacketFunctions use Promises, You can use Promise methods to handle results:

Network.Server.RequestData:Invoke(nil, data):andThen(function(result)
-- handle on success
end):catch(function(err)
-- handle on error
end)