Informacje o wersji
Edukacja
Klasa silnika
TextChatService
Brak możliwości tworzenia
Usługa

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.


Podsumowanie
Metody
CanUsersChatAsync(userIdFrom: User,userIdTo: User):boolean
CanUsersDirectChatAsync(requesterUserId: User,userIds: {any}):{any}
DisplayBubble(partOrCharacter: Instance,message: string):()
GetChatGroupsAsync(players: Instances):{any}
Członkowie odziedziczeni

Materiały referencyjne dotyczące interfejsów API
Właściwości
ChatTranslationEnabled
Bez replikacji
Zabezpieczenia skryptów Roblox
Odczyt równoległy
Możliwości: Chat
TextChatService.ChatTranslationEnabled:boolean

ChatVersion
Przestarzałe

CreateDefaultCommands
Zabezpieczenia dodatku plug-in
Odczyt równoległy
Możliwości: Chat
TextChatService.CreateDefaultCommands:boolean

CreateDefaultTextChannels
Zabezpieczenia dodatku plug-in
Odczyt równoległy
Możliwości: Chat
TextChatService.CreateDefaultTextChannels:boolean

Metody
CanUserChatAsync
Wynik
Możliwości: Chat
TextChatService:CanUserChatAsync(userId:User):boolean
Parametry
userId:User
Zwroty

CanUsersChatAsync
Wynik
Możliwości: Chat
TextChatService:CanUsersChatAsync(
userIdFrom:User, userIdTo:User
Parametry
userIdFrom:User
userIdTo:User
Zwroty

CanUsersDirectChatAsync
Wynik
Możliwości: Chat
TextChatService:CanUsersDirectChatAsync(
requesterUserId:User, userIds:{any}
Parametry
requesterUserId:User
userIds:{any}
Zwroty
Przykłady kodu
CanUsersDirectChatAsync
local TextChatService = game:GetService("TextChatService")
local directChatParticipants = TextChatService:CanUsersDirectChatAsync(userId1, { userId2 })
-- Sprawdź, czy są uprawnieni uczestnicy
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("Nie można stworzyć TextChannel. Za mało uprawnionych użytkowników.")
return nil

DisplayBubble
Możliwości: Chat
TextChatService:DisplayBubble(
partOrCharacter:Instance, message:string
):()
Parametry
partOrCharacter:Instance
message:string
Zwroty
()

GetChatGroupsAsync
Wynik
Możliwości: Chat
TextChatService:GetChatGroupsAsync(players:Instances):{any}
Parametry
players:Instances
Zwroty
Przykłady kodu
TeleportujGraczaDoNajlepszegoSerweraCzatu
-- Skrypt serwera
local TextChatService = game:GetService("TextChatService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local TARGET_PLACE_ID = 1234567890 -- ID miejsca docelowego
--[[
Szkielety uniwersalnego stanu serwera.
W praktyce, te dane mogą być przechowywane i aktualizowane przy użyciu MemoryStore
lub innego systemu zaplecza.
Przykładowy kształt:
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("Nie udało się pobrać grup czatu dla gracza:", player.UserId)
return
end
-- Zbieranie wszystkich identyfikatorów grup czatu, do których gracz jest uprawniony
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
-- Wybierz serwer z największą liczbą kompatybilnych użytkowników
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("Nie znaleziono odpowiedniego serwera dla gracza:", player.UserId)
return
end
local ok, err = pcall(function()
TeleportService:TeleportToPrivateServer(
TARGET_PLACE_ID,
bestServer.accessCode,
{ player }
)
end)
if not ok then
warn("Teleportacja nie powiodła się:", err)
end
end
Players.PlayerAdded:Connect(teleportPlayerToBestServer)

Zdarzenia
BubbleDisplayed
Możliwości: Chat
TextChatService.BubbleDisplayed(
partOrCharacter:Instance, textChatMessage:TextChatMessage
Parametry
partOrCharacter:Instance
textChatMessage:TextChatMessage

MessageReceived
Możliwości: Chat
TextChatService.MessageReceived(textChatMessage:TextChatMessage):RBXScriptSignal
Parametry
textChatMessage:TextChatMessage

SendingMessage
Możliwości: Chat
TextChatService.SendingMessage(textChatMessage:TextChatMessage):RBXScriptSignal
Parametry
textChatMessage:TextChatMessage

Wywołania zwrotne
OnBubbleAdded
Możliwości: Chat
TextChatService.OnBubbleAdded(
message:TextChatMessage, adornee:Instance
Parametry
adornee:Instance
Zwroty

OnChatWindowAdded
Możliwości: Chat
TextChatService.OnChatWindowAdded(message:TextChatMessage):Tuple
Parametry
Zwroty

OnIncomingMessage
Możliwości: Chat
TextChatService.OnIncomingMessage(message:TextChatMessage):Tuple
Parametry
Zwroty

©2026 Roblox Corporation. Nazwa Roblox, logo Roblox oraz hasło „Powering Imagination” należą do naszych zarejestrowanych i niezarejestrowanych znaków towarowych na terenie Stanów Zjednoczonych oraz w innych krajach.