学ぶ
エンジンクラス
TextChatService
作成できません
サービス

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


概要
方法
CanUsersChatAsync(userIdFrom: User,userIdTo: User):boolean
CanUsersDirectChatAsync(requesterUserId: User,userIds: {any}):{any}
DisplayBubble(partOrCharacter: Instance,message: string):()
GetChatGroupsAsync(players: Instances):{any}
継承されたメンバー

APIリファレンス
プロパティ
ChatTranslationEnabled
複製されていません
Robloxのスクリプトセキュリティ
並列読み取り
機能: Chat
TextChatService.ChatTranslationEnabled:boolean

ChatVersion
非推奨

CreateDefaultCommands
プラグインのセキュリティ
並列読み取り
機能: Chat
TextChatService.CreateDefaultCommands:boolean

CreateDefaultTextChannels
プラグインのセキュリティ
並列読み取り
機能: Chat
TextChatService.CreateDefaultTextChannels:boolean

方法
CanUserChatAsync
イールド
機能: Chat
TextChatService:CanUserChatAsync(userId:User):boolean
パラメータ
userId:User
戻り値

CanUsersChatAsync
イールド
機能: Chat
TextChatService:CanUsersChatAsync(
userIdFrom:User, userIdTo:User
パラメータ
userIdFrom:User
userIdTo:User
戻り値

CanUsersDirectChatAsync
イールド
機能: Chat
TextChatService:CanUsersDirectChatAsync(
requesterUserId:User, userIds:{any}
パラメータ
requesterUserId:User
userIds:{any}
戻り値
コードサンプル
ユーザーが直接チャットできるか非同期で確認
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- 対象となる参加者を確認します
if #directChatParticipants > 0 then
local directChannel = Instance.new("TextChannel")
directChannel.Parent = TextChatService
for _, participant in directChatParticipants do
directChannel:AddUserAsync(participant)
end
return directChannel
end
warn("TextChannelを作成できませんでした。対象ユーザーが不足しています。")
return nil

DisplayBubble
機能: Chat
TextChatService:DisplayBubble(
partOrCharacter:Instance, message:string
):()
パラメータ
partOrCharacter:Instance
message:string
戻り値
()

GetChatGroupsAsync
イールド
機能: Chat
TextChatService:GetChatGroupsAsync(players:Instances):{any}
パラメータ
players:Instances
戻り値
コードサンプル
最適なチャットサーバーにプレイヤーをテレポート
-- サーバースクリプト
local TextChatService = game:GetService("TextChatService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local TARGET_PLACE_ID = 1234567890 -- 目的地のプレイスID
--[[
ユニバース全体のサーバーステートのスタブ。
実際には、このデータはMemoryStore
や他のバックエンドシステムを使用して保存および更新できます。
例の構造:
ActiveServers = {
{
serverId = "abc",
accessCode = "reserved-server-code",
groupUserCounts = {
groupA = 12,
groupB = 5
}
},
{
serverId = "def",
accessCode = "reserved-server-code",
groupUserCounts = {
groupB = 8
}
}
}
]]
local ActiveServers = {}
local function teleportPlayerToBestServer(player)
local success, chatGroups = pcall(function()
return TextChatService:GetChatGroupsAsync({ player })
end)
if not success or not chatGroups then
warn("プレイヤーのチャットグループを取得できませんでした:", player.UserId)
return
end
-- プレイヤーが対象となるすべてのチャットグループIDを収集
local playerGroupIds = {}
for _, group in ipairs(chatGroups) do
for _, groupId in ipairs(group) do
playerGroupIds[groupId] = true
end
end
local bestServer = nil
local bestUserCount = 0
-- 最も多くの互換性のあるユーザーを持つサーバーを選択
for _, server in ipairs(ActiveServers) do
local compatibleUserCount = 0
for groupId, userCount in pairs(server.groupUserCounts) do
if playerGroupIds[groupId] then
compatibleUserCount += userCount
end
end
if compatibleUserCount > bestUserCount then
bestUserCount = compatibleUserCount
bestServer = server
end
end
if not bestServer then
warn("プレイヤーに適したサーバーが見つかりませんでした:", player.UserId)
return
end
local ok, err = pcall(function()
TeleportService:TeleportToPrivateServer(
TARGET_PLACE_ID,
bestServer.accessCode,
{ player }
)
end)
if not ok then
warn("テレポートに失敗しました:", err)
end
end
Players.PlayerAdded:Connect(teleportPlayerToBestServer)

イベント
BubbleDisplayed
機能: Chat
TextChatService.BubbleDisplayed(
partOrCharacter:Instance, textChatMessage:TextChatMessage
パラメータ
partOrCharacter:Instance
textChatMessage:TextChatMessage

MessageReceived
機能: Chat
TextChatService.MessageReceived(textChatMessage:TextChatMessage):RBXScriptSignal
パラメータ
textChatMessage:TextChatMessage

SendingMessage
機能: Chat
TextChatService.SendingMessage(textChatMessage:TextChatMessage):RBXScriptSignal
パラメータ
textChatMessage:TextChatMessage

コールバック
OnBubbleAdded
機能: Chat
TextChatService.OnBubbleAdded(
message:TextChatMessage, adornee:Instance
パラメータ
adornee:Instance
戻り値

OnChatWindowAdded
機能: Chat
TextChatService.OnChatWindowAdded(message:TextChatMessage):Tuple
パラメータ
戻り値

OnIncomingMessage
機能: Chat
TextChatService.OnIncomingMessage(message:TextChatMessage):Tuple
パラメータ
戻り値

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