Trying to use a chat module to create chat tags

I’ve looked at a number of different videos on how to do this now… every one of them is just a bit too outdated and doesn’t work. I’ve managed to find one that really should work, but instead of working it breaks chat entirely. No typing, no messages, no GUI. If anyone knows anything about the basic chat functions and sending messages, can someone please tell me why this is broken?
Module script getting the player tags based on what they own or who they are. In this case, the only thing I have is my user ID-

local ms = game:GetService("MarketplaceService")

local players = {
    [72490169] = {title = 'Dev', priority = 5, color = Color3.fromRGB(255, 0, 191)}
}

function sendInfo(player)

    local info = nil
    local priority = 0


    for key, value in pairs(players) do
	    if player.UserId == key and value.priority > priority then
		    info = {title = value.title, color = value.color}
		    priority = value.priority
	    end
    end

    return info

end

return sendInfo()

I think this script is fine, but there’s no way to check without having the first script work. If you want to look at it in full it gets created under the service chat and is called “DefaultChatMessage” Here’s a little tidbit of what I edited on to try to get it to work

Original-

local clientChatModules = script.Parent.Parent
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local util = require(script.Parent:WaitForChild("Util"))

function CreateMessageLabel(messageData, channelName)

    local fromSpeaker = messageData.FromSpeaker
    local message = messageData.Message

    local extraData = messageData.ExtraData or {}
    local useFont = extraData.Font or ChatSettings.DefaultFont
    local useTextSize = extraData.TextSize or ChatSettings.ChatWindowTextSize
    local useNameColor = extraData.NameColor or ChatSettings.DefaultNameColor
    local useChatColor = extraData.ChatColor or ChatSettings.DefaultMessageColor
    local useChannelColor = extraData.ChannelColor or useChatColor
    local tags = extraData.Tags or {}

    local formatUseName = string.format("[%s:]", fromSpeaker)

…and more

Edited-

local clientChatModules = script.Parent.Parent
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local util = require(script.Parent:WaitForChild("Util"))
local titleModule = require(game:GetService("Chat").titleModule)

function CreateMessageLabel(messageData, channelName)

    local fromSpeaker = messageData.FromSpeaker
	local message = messageData.Message

    local extraData = messageData.ExtraData or {}
    local useFont = extraData.Font or ChatSettings.DefaultFont
    local useTextSize = extraData.TextSize or ChatSettings.ChatWindowTextSize
	local useNameColor = extraData.NameColor or ChatSettings.DefaultNameColor
    local useChatColor = extraData.ChatColor or ChatSettings.DefaultMessageColor
    local useChannelColor = extraData.ChannelColor or useChatColor
    local tags = extraData.Tags or {}

    local info = titleModule(game:GetService("Players"):FindFirstChild(tostring(fromSpeaker)))

    local formatUseName

    if info then
	    formatUseName = string.format("[" .. info.title .. "] %s:", fromSpeaker)
	    useNameColor = info.color
	    useChatColor = info.color
    else
	    formatUseName = string.format("%s:", fromSpeaker)
    end

…and more

There’s more but it’s a long script to put into this. If I comment out ALL of the added parts from the original script, then it works, but otherwise even a single variable left out breaks the whole thing.

If you have a way to fix this, or a different way to do this, I’m desperate… please and thank you :')

1 Like

Here’s something I’ve been using for quite a while now. Make sure you set the “LoadDefaultChat” property to FALSE in the Chat Service. Allows for custom tags and chat colors.

Thank you, but I’m not exactly sure how to implement “Chat” and “ChatServiceRunner”
Could you explain by any chance?

You don’t have to edit the chat modules. You can use roblox’s Lua Chat System api function SetExtraData to assign tags to players.

Example:

local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = {
    [72490169] = {{TagText = "Dev", TagColor = Color3.fromRGB(255,0,191)}}
}
game.Players.PlayerAdded:Connect(function(plr)
    if Players[plr.UserId] then
        local speaker = ChatService:GetSpeaker(plr.Name)
        if speaker then
            speaker:SetExtraData("Tags", Players[plr.UserId])
        end
    end
end
1 Like

All you do is just put it in the Workspace. It installs itself.

1 Like

I made a video on this

Similar to what Kiriot said, this can be done without a separate module or forking and modifying the chat source. To quote sircfenner from a separate post:

Make sure to search before making a topic; there are many very similar to this one.