Aprenda
Classe do mecanismo
TextChatService
Não criável
Serviço

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.



Referência API
Propriedades
ChatTranslationEnabled
Não replicado
Segurança do script Roblox
Ler Parallel
Recursos: Chat
TextChatService.ChatTranslationEnabled:boolean

ChatVersion
Obsoleto

CreateDefaultCommands
Segurança do plugin
Ler Parallel
Recursos: Chat
TextChatService.CreateDefaultCommands:boolean

CreateDefaultTextChannels
Segurança do plugin
Ler Parallel
Recursos: Chat
TextChatService.CreateDefaultTextChannels:boolean

Métodos
CanUserChatAsync
Rendimentos
Recursos: Chat
TextChatService:CanUserChatAsync(userId:User):boolean
Parâmetros
userId:User
Devolução

CanUsersChatAsync
Rendimentos
Recursos: Chat
TextChatService:CanUsersChatAsync(
userIdFrom:User, userIdTo:User
Parâmetros
userIdFrom:User
userIdTo:User
Devolução

CanUsersDirectChatAsync
Rendimentos
Recursos: Chat
TextChatService:CanUsersDirectChatAsync(
requesterUserId:User, userIds:{any}
Parâmetros
requesterUserId:User
userIds:{any}
Devolução
Amostras de código
PodeUsuariosConversarDiretamenteAsync
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- Verifique os participantes elegíveis
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("Não foi possível criar o TextChannel. Usuários elegíveis insuficientes.")
return nil

DisplayBubble
Recursos: Chat
TextChatService:DisplayBubble(
partOrCharacter:Instance, message:string
):()
Parâmetros
partOrCharacter:Instance
message:string
Devolução
()

GetChatGroupsAsync
Rendimentos
Recursos: Chat
TextChatService:GetChatGroupsAsync(players:Instances):{any}
Parâmetros
players:Instances
Devolução
Amostras de código
TeletransportarJogadorParaMelhorServidorDeChat
-- Script do Servidor
local TextChatService = game:GetService("TextChatService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local TARGET_PLACE_ID = 1234567890 -- ID do lugar de destino
--[[
Estado do servidor em todo o universo.
Na prática, esses dados poderiam ser armazenados e atualizados usando MemoryStore
ou outro sistema backend.
Exemplo de estrutura:
ActiveServers = {
{
serverId = "abc",
accessCode = "código-de-servidor-reservado",
groupUserCounts = {
groupA = 12,
groupB = 5
}
},
{
serverId = "def",
accessCode = "código-de-servidor-reservado",
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("Falha ao recuperar grupos de chat para o jogador:", player.UserId)
return
end
-- Coletar todos os IDs de grupos de chat que o jogador é elegível
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
-- Escolher o servidor com o maior número de usuários compatíveis
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("Nenhum servidor adequado encontrado para o jogador:", player.UserId)
return
end
local ok, err = pcall(function()
TeleportService:TeleportToPrivateServer(
TARGET_PLACE_ID,
bestServer.accessCode,
{ player }
)
end)
if not ok then
warn("Teletransporte falhou:", err)
end
end
Players.PlayerAdded:Connect(teleportPlayerToBestServer)

Eventos
BubbleDisplayed
Recursos: Chat
TextChatService.BubbleDisplayed(
partOrCharacter:Instance, textChatMessage:TextChatMessage
Parâmetros
partOrCharacter:Instance
textChatMessage:TextChatMessage

MessageReceived
Recursos: Chat
TextChatService.MessageReceived(textChatMessage:TextChatMessage):RBXScriptSignal
Parâmetros
textChatMessage:TextChatMessage

SendingMessage
Recursos: Chat
TextChatService.SendingMessage(textChatMessage:TextChatMessage):RBXScriptSignal
Parâmetros
textChatMessage:TextChatMessage

Callbacks
OnBubbleAdded
Recursos: Chat
TextChatService.OnBubbleAdded(
message:TextChatMessage, adornee:Instance
Parâmetros
adornee:Instance
Devolução

OnChatWindowAdded
Recursos: Chat
TextChatService.OnChatWindowAdded(message:TextChatMessage):Tuple
Parâmetros
Devolução

OnIncomingMessage
Recursos: Chat
TextChatService.OnIncomingMessage(message:TextChatMessage):Tuple
Parâmetros
Devolução

©2026 Roblox Corporation, Roblox, o logotipo Roblox e Powering Imagination estão entre nossas marcas registradas e não registradas nos EUA e em outros países.