Custom Chat Tags

Learn how to add custom chat tags to your game!

by fivefactor

Author Avatar

Custom Chat Tags

Creating custom chat tags for certain players in your game is fairly simple. You can start off by creating a Script in ServerScriptService.

We are creating the script in ServerScriptService becuase that is where the ChatServiceRunner is located when the game starts

Let's start off by defining Players

local Players = game:GetService("Players")

Our next step is to create a variable for our chat tag and assign it to a certain username. The code example provided would give the "Owner" tag to "UndecidedFactor" and "boatbomber".

local Owner = {UndecidedFactor = true, boatbomber = true}

Next, let's add a PlayerAdded function where we will set the tags. We will also add the ChatService variable inside this function because the player loads before ChatService.

Players.PlayerAdded:Connect(function(player)
    local ChatService = require(script.Parent.Parent.Parent:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
end)

After we create our PlayerAdded function, we'll assign the tags to the player. Our updated PlayerAdded function will now look like this:

Players.PlayerAdded:Connect(function(player)
    wait(2)
-- Lets wait a few seconds to make sure the chat loaded
    local ChatService = require(script.Parent.Parent.Parent:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
    if Owner[player.Name] then
 -- We add this to check if the players username is in the Owner table
        local Speaker = ChatService:GetSpeaker(player.Name)
-- The person chatting is the speaker
        Speaker:SetExtraData("Tags", {{TagText = "Owner", TagColor = Color3.fromRGB(100, 10, 50)}})
-- Here we add a tag with the text "Owner" and we can also set the color
    end
end)

Our final code should now look like this:

local Players = game:GetService("Players")

local Owner = {UndecidedFactor = true, boatbomber = true}

Players.PlayerAdded:Connect(function(player)
    wait(2)
    local ChatService = require(script.Parent.Parent.Parent:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
    if Owner[player.Name] then
        local Speaker = ChatService:GetSpeaker(player.Name)
        Speaker:SetExtraData("Tags", {{TagText = "Owner", TagColor = Color3.fromRGB(100, 10, 50)}})    end
end)

That's all! If you have any questions regarding the tutorial feel free to message UndecidedFactor on Roblox.

View in-game to comment, award, and more!