채팅 태그 할당

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

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

채팅 창에 사용자 이름에 추가된 VIP 채팅 태그.

text chat callbacks는 비차단 콜백을 기대하므로, TextChatService.OnIncomingMessage 콜백에서 플레이어의 그룹 멤버십 상태를 쿼리하려고 하면 안 됩니다. 이렇게 하면 채팅 시스템이 멈추거나 응답하지 않을 수 있습니다.

대신, 플레이어가 서버에 입장할 때 속성을 설정하세요. 속성을 설정하면 플레이어의 상태를 재사용할 수 있어 특정 영역에 대한 접근 허용 또는 보너스 경험 제공 등의 다양한 게임의 다른 부분에서 활용할 수 있습니다.

  1. ServerScriptServiceScript를 생성하고 다음 코드를 추가합니다:

    Server

    local Players = game:GetService("Players")
    -- 확인할 그룹 ID를 123456으로 변경하세요
    local groupID = 123456
    Players.PlayerAdded:Connect(function(player)
    local success, isInGroup = pcall(function()
    return player:IsInGroupAsync(groupID)
    end)
    if success and isInGroup then
    player:SetAttribute("IsVIP", true)
    else
    player:SetAttribute("IsVIP", false)
    end
    end)
  2. StarterPlayerStarterCharacterScriptsLocalScript를 생성하고 채팅 창에 [VIP] 태그를 표시하는 다음 코드를 추가합니다:

    Client

    local Players = game:GetService("Players")
    local TextChatService = game:GetService("TextChatService")
    TextChatService.OnIncomingMessage = function(message: TextChatMessage)
    local textSource = message.TextSource
    if textSource then
    local player = Players:GetPlayerByUserId(textSource.UserId)
    if player then
    if player:GetAttribute("IsVIP") == true then
    local overrideProperties = Instance.new("TextChatMessageProperties")
    overrideProperties.PrefixText = "[VIP] " .. message.PrefixText
    return overrideProperties
    end
    end
    end
    return nil
    end
©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.