Apprendre
Classe de moteur
TextChatService
Création impossible
Service

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.



Référence API
Propriétés
ChatTranslationEnabled
Non répliqué
Sécurité des scripts Roblox
Lecture parallèle
Capacités : Chat
TextChatService.ChatTranslationEnabled:boolean

ChatVersion
Déprécié

CreateDefaultCommands
Sécurité des plugins
Lecture parallèle
Capacités : Chat
TextChatService.CreateDefaultCommands:boolean

CreateDefaultTextChannels
Sécurité des plugins
Lecture parallèle
Capacités : Chat
TextChatService.CreateDefaultTextChannels:boolean

Méthodes
CanUserChatAsync
Rendement
Capacités : Chat
TextChatService:CanUserChatAsync(userId:User):boolean
Paramètres
userId:User
Retours

CanUsersChatAsync
Rendement
Capacités : Chat
TextChatService:CanUsersChatAsync(
userIdFrom:User, userIdTo:User
Paramètres
userIdFrom:User
userIdTo:User
Retours

CanUsersDirectChatAsync
Rendement
Capacités : Chat
TextChatService:CanUsersDirectChatAsync(
requesterUserId:User, userIds:{any}
Paramètres
requesterUserId:User
userIds:{any}
Retours
Échantillons de code
CanUsersDirectChatAsync
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- Vérifiez les participants éligibles
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("Impossible de créer TextChannel. Pas assez d'utilisateurs éligibles.")
return nil

DisplayBubble
Capacités : Chat
TextChatService:DisplayBubble(
partOrCharacter:Instance, message:string
):()
Paramètres
partOrCharacter:Instance
message:string
Retours
()

GetChatGroupsAsync
Rendement
Capacités : Chat
TextChatService:GetChatGroupsAsync(players:Instances):{any}
Paramètres
players:Instances
Retours
Échantillons de code
TéléporterJoueurAuMeilleurServeurDeChat
-- Script Serveur
local TextChatService = game:GetService("TextChatService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local TARGET_PLACE_ID = 1234567890 -- ID du lieu de destination
--[[
État du serveur universel en mode stub.
Dans la pratique, ces données pourraient être stockées et mises à jour à l'aide de MemoryStore
ou d'un autre système backend.
Exemple de forme :
ActiveServers = {
{
serverId = "abc",
accessCode = "code-serveur-réservé",
groupUserCounts = {
groupA = 12,
groupB = 5
}
},
{
serverId = "def",
accessCode = "code-serveur-réservé",
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("Échec de la récupération des groupes de chat pour le joueur :", player.UserId)
return
end
-- Rassembler tous les IDs de groupe de chat auxquels le joueur est éligible
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
-- Choisir le serveur avec le plus grand nombre d'utilisateurs compatibles
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("Aucun serveur approprié trouvé pour le joueur :", player.UserId)
return
end
local ok, err = pcall(function()
TeleportService:TeleportToPrivateServer(
TARGET_PLACE_ID,
bestServer.accessCode,
{ player }
)
end)
if not ok then
warn("Échec du téléport :", err)
end
end
Players.PlayerAdded:Connect(teleportPlayerToBestServer)

Événements
BubbleDisplayed
Capacités : Chat
TextChatService.BubbleDisplayed(
partOrCharacter:Instance, textChatMessage:TextChatMessage
Paramètres
partOrCharacter:Instance
textChatMessage:TextChatMessage

MessageReceived
Capacités : Chat
TextChatService.MessageReceived(textChatMessage:TextChatMessage):RBXScriptSignal
Paramètres
textChatMessage:TextChatMessage

SendingMessage
Capacités : Chat
TextChatService.SendingMessage(textChatMessage:TextChatMessage):RBXScriptSignal
Paramètres
textChatMessage:TextChatMessage

Rappels
OnBubbleAdded
Capacités : Chat
TextChatService.OnBubbleAdded(
message:TextChatMessage, adornee:Instance
Paramètres
adornee:Instance
Retours

OnChatWindowAdded
Capacités : Chat
TextChatService.OnChatWindowAdded(message:TextChatMessage):Tuple
Paramètres
Retours

OnIncomingMessage
Capacités : Chat
TextChatService.OnIncomingMessage(message:TextChatMessage):Tuple
Paramètres
Retours

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.