This example demonstrates how to assign chat tags to players based on their membership in a group. Chat tags are a way to visually identify a player in the chat window and useful for indicating a player's role or status.

Because text chat callbacks expect a non-yielding callback, attempting to query the group membership status of a player in the TextChatService.OnIncomingMessage callback is not recommended, as it may cause the chat system to hang or become unresponsive.
Instead, set a player attribute when they join the server. Setting an attribute lets you reuse the player's status in other parts of your experience such as allowing access to particular areas or providing bonus experience.
Create a Script in ServerScriptService and add the following code to it:
Serverlocal Players = game:GetService("Players")-- Replace 123456 with the group ID you want to check forlocal 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)Create a LocalScript in StarterPlayer ⟩ StarterCharacterScripts and add the following code to display a [VIP] tag in the chat window:
Clientlocal 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