이 예제에서는 채팅 태그를 그룹 가입에 따라 플레이어에게 할당하는 방법을 보여줍니다.채팅 태그는 채팅 창에서 플레이어를 시각적으로 식별하고 플레이어의 역할이나 상태를 나타내는 데 유용한 방법입니다.

왜냐하면 텍스트 채팅 콜백은 양보할 수 없는 콜백을 기대하기 때문에, TextChatService.OnIncomingMessage 채팅 시스템이 멈추거나 반응하지 않을 수 있기 때문에 콜백에서 플레이어의 그룹 회원 상태를 쿼리하려는 것은 권장되지 않습니다.
대신, 플레이어가 서버에 참여할 때 플레이어 특성을 설정합니다.특성을 설정하면 특정 영역에 대한 액세스를 허용하거나 보너스 경험을 제공하는 등 경험의 다른 부분에서 플레이어의 상태를 재사용할 수 있습니다.
Create a Script in ServerScriptService 및 다음 코드를 추가하십시오:
서버local Players = game:GetService("Players")-- 123456를 확인하려는 그룹 ID로 바꾸기local groupID = 123456Players.PlayerAdded:Connect(function(player)local success, isInGroup = pcall(function()return player:IsInGroup(groupID)end)if success and isInGroup thenplayer:SetAttribute("IsVIP", true)elseplayer:SetAttribute("IsVIP", false)endend)채팅 창에 [VIP] 태그를 표시하기 위해 내에 및 다음 코드를 추가하십시오:
클라이ентlocal Players = game:GetService("Players")local TextChatService = game:GetService("TextChatService")TextChatService.OnIncomingMessage = function(message: TextChatMessage)local textSource = message.TextSourceif textSource thenlocal player = Players:GetPlayerByUserId(textSource.UserId)if player thenif player:GetAttribute("IsVIP") == true thenlocal overrideProperties = Instance.new("TextChatMessageProperties")overrideProperties.PrefixText = "[VIP] " .. message.PrefixTextreturn overridePropertiesendendendreturn nilend