Impara
Classe motore
TextChatService
Non costruibile
Assistenza

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.


Sommario
Metodi
CanUsersChatAsync(userIdFrom: User,userIdTo: User):boolean
CanUsersDirectChatAsync(requesterUserId: User,userIds: {any}):{any}
DisplayBubble(partOrCharacter: Instance,message: string):()
GetChatGroupsAsync(players: Instances):{any}
Membri ereditati

Riferimento API
Proprietà
ChatTranslationEnabled
Non Replicato
Sicurezza Script Roblox
Lettura Parallela
Capacità: Chat
TextChatService.ChatTranslationEnabled:boolean

ChatVersion
Obsoleto

CreateDefaultCommands
Sicurezza Plugin
Lettura Parallela
Capacità: Chat
TextChatService.CreateDefaultCommands:boolean

CreateDefaultTextChannels
Sicurezza Plugin
Lettura Parallela
Capacità: Chat
TextChatService.CreateDefaultTextChannels:boolean

Metodi
CanUserChatAsync
Resa
Capacità: Chat
TextChatService:CanUserChatAsync(userId:User):boolean
Parametri
userId:User
Restituzioni

CanUsersChatAsync
Resa
Capacità: Chat
TextChatService:CanUsersChatAsync(
userIdFrom:User, userIdTo:User
Parametri
userIdFrom:User
userIdTo:User
Restituzioni

CanUsersDirectChatAsync
Resa
Capacità: Chat
TextChatService:CanUsersDirectChatAsync(
requesterUserId:User, userIds:{any}
Parametri
requesterUserId:User
userIds:{any}
Restituzioni
Campioni di codice
CanUsersDirectChatAsync
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- Verifica i partecipanti idonei
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("Impossibile creare TextChannel. Non ci sono utenti idonei sufficienti.")
return nil

DisplayBubble
Capacità: Chat
TextChatService:DisplayBubble(
partOrCharacter:Instance, message:string
):()
Parametri
partOrCharacter:Instance
message:string
Restituzioni
()

GetChatGroupsAsync
Resa
Capacità: Chat
TextChatService:GetChatGroupsAsync(players:Instances):{any}
Parametri
players:Instances
Restituzioni
Campioni di codice
TeletrasportaGiocatoreAlMigliorServerChat
-- Script del server
local TextChatService = game:GetService("TextChatService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local TARGET_PLACE_ID = 1234567890 -- ID del posto di destinazione
--[[
Stato del server universale stub.
In pratica, questi dati potrebbero essere memorizzati e aggiornati utilizzando MemoryStore
o un altro sistema backend.
Forma esempio:
ActiveServers = {
{
serverId = "abc",
accessCode = "codice-server-riservato",
groupUserCounts = {
groupA = 12,
groupB = 5
}
},
{
serverId = "def",
accessCode = "codice-server-riservato",
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("Impossibile recuperare i gruppi chat per il giocatore:", player.UserId)
return
end
-- Raccogli tutti gli ID dei gruppi chat ai quali il giocatore è idoneo
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
-- Scegli il server con il numero maggiore di utenti compatibili
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("Nessun server adatto trovato per il giocatore:", player.UserId)
return
end
local ok, err = pcall(function()
TeleportService:TeleportToPrivateServer(
TARGET_PLACE_ID,
bestServer.accessCode,
{ player }
)
end)
if not ok then
warn("Teleport fallito:", err)
end
end
Players.PlayerAdded:Connect(teleportPlayerToBestServer)

Eventi
BubbleDisplayed
Capacità: Chat
TextChatService.BubbleDisplayed(
partOrCharacter:Instance, textChatMessage:TextChatMessage
Parametri
partOrCharacter:Instance
textChatMessage:TextChatMessage

MessageReceived
Capacità: Chat
TextChatService.MessageReceived(textChatMessage:TextChatMessage):RBXScriptSignal
Parametri
textChatMessage:TextChatMessage

SendingMessage
Capacità: Chat
TextChatService.SendingMessage(textChatMessage:TextChatMessage):RBXScriptSignal
Parametri
textChatMessage:TextChatMessage

Richiami
OnBubbleAdded
Capacità: Chat
TextChatService.OnBubbleAdded(
message:TextChatMessage, adornee:Instance
Parametri
adornee:Instance
Restituzioni

OnChatWindowAdded
Capacità: Chat
TextChatService.OnChatWindowAdded(message:TextChatMessage):Tuple
Parametri
Restituzioni

OnIncomingMessage
Capacità: Chat
TextChatService.OnIncomingMessage(message:TextChatMessage):Tuple
Parametri
Restituzioni

© 2026 Roblox Corporation. Roblox, il logo Roblox e Powering Imagination sono tra i nostri marchi registrati e non registrati negli Stati Uniti. e altri paesi.