学ぶ
エンジンクラス
MessagingService
作成できません
サービス
複製されていません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要
方法
PublishAsync(topic: string,message: Variant):()
継承されたメンバー

APIリファレンス
方法
PublishAsync
イールド
機能: ServerCommunication
MessagingService:PublishAsync(
topic:string, message:Variant
):()
パラメータ
topic:string
message:Variant
戻り値
()

SubscribeAsync
イールド
機能: ServerCommunication
MessagingService:SubscribeAsync(
topic:string, callback:function
パラメータ
topic:string
callback:function
コードサンプル
クロスサーバーメッセージへのサブスクリプション
local MessagingService = game:GetService("MessagingService")
local Players = game:GetService("Players")
local function onPlayerAdded(player)
-- トピックにサブスクライブ
local topic = "player-" .. player.UserId
local connection = MessagingService:SubscribeAsync(topic, function(message)
print("Received message for", player.Name, message.Data)
end)
player.AncestryChanged:Connect(function()
-- トピックからサブスクリプションを解除
connection:Disconnect()
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。