Skip to content

Service · inherits Instance

MessagingService

Official docs ↗

Allows servers of the same experience to communicate with each other.

About MessagingService

MessagingService allows servers of the same experience to communicate with each other in real time, typically within 1-2 seconds, using topics. Topics are developer‑defined strings (1–80 characters) that servers use to send and receive messages.

Delivery is best effort and not guaranteed. Make sure to architect your experience so delivery failures are not critical.

Cross-Server Messaging explores how to communicate between servers in greater detail.

If you want to publish ad-hoc messages to live game servers, or publish across experiences, you can use the Open Cloud APIs.

Limitations

Note that these limits are subject to change.

Methods 2

  • PublishAsync(topic: string, message: Variant) → ()YieldsInvokes the supplied callback whenever a message is pushed to the topic.

    This function sends the provided message to all subscribers to the topic, triggering their registered callbacks to be invoked.

    Yields until the message is received by the backend.

  • SubscribeAsync(topic: string, callback: Function) → RBXScriptConnectionYieldsBegins listening to the given topic.

    This function registers a callback to begin listening to the given topic. The callback is invoked when a topic receives a message. It can be called multiple times for the same topic.

    Callback

    The callback is invoked with a single argument, a table with the following entries:

    It yields until the subscription is properly registered and returns a connection object.

    To unsubscribe, call Disconnect() on the returned object. Once called, the callback should never be invoked. Killing the script containing the connections also causes the underlying connect to be unsubscribed.

    See also MessagingService.PublishAsync which sends the provided message to all subscribers to the topic, triggering their registered callbacks to be invoked.

MessagingService also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.