User Chat Titles

So I’ve been trying to get chat titles for my group game for quite a while and I came across a few forums on the site but most have seemed to not work. I tried Coasterteam’s script and as he said put it in ServerScriptService but it never worked.

This was the script he has made down below.

--[==[ START VARIABLES ]==]--

local Players = game:GetService("Players")
local ScriptService = game:GetService("ServerScriptService")
local ChatService = require(ScriptService:WaitForChild("ChatServiceRunner").ChatService)

--[==[ END VARIABLES ]==]--

--[==[ START TABLE FOR TAGS ]==]--

--[==[ 
	FORMAT:
	["RankInGroup"] = {TagText = "TagTextHere", TagColor = Color3.fromRGB(r, g, b)} 
]==]--

local ranks = {
    ["255"] = {TagText = "Lead Developer", TagColor = Color3.fromRGB(233,30,99)},
    ["250"] = {TagText = "Lead Scripter", TagColor = Color3.fromRGB(230,126,34)},
    ["225"] = {TagText = "Place Developer", TagColor = Color3.fromRGB(230,126,34)},
    ["200"] = {TagText = "Asset Developer", TagColor = Color3.fromRGB(46,204,113)},
    ["150"] = {TagText = "Moderator", TagColor = Color3.fromRGB(32,102,148)},
    ["100"] = {TagText = "Moderator-In-Training", TagColor = Color3.fromRGB(76,188,206)},
}

--[==[ END TABLE FOR TAGS ]==]--


--[==[ GROUP ID ]==]--
local groupId = 3108202
--[==[ GROUP ID ]==]--

ChatService.SpeakerAdded:Connect(function(SpeakerName) -- Wait for a speaker to be added to Chat
	
    if game.Players:FindFirstChild(SpeakerName) then -- Makes sure the speaker is a real player
	
		local plr = game.Players:FindFirstChild(SpeakerName) -- Get the player Object
	
        local UserId = plr.UserId -- Getting the UserId of the speaker
        local Speaker = ChatService:GetSpeaker(SpeakerName) -- Getting the Speaker Object from ChatService

        if plr.UserId == 26666928  then -- Replace 26666928 with your own ID
	
              Speaker:SetExtraData("Tags", {{TagText = "Script Developer", TagColor = Color3.fromRGB(241,196,15)}}) -- Customize the text and color to your liking
              Speaker:SetExtraData("NameColor", Color3.fromRGB(241,196,15)) -- Set the name color to the tag color

        elseif plr:IsInGroup(groupId) then -- If player is in the group, check the rank
	
            local rank = plr:GetRankInGroup(groupId)

            for i,tag in pairs(ranks) do -- Loop through the ranks table
	
                if i == tostring(rank) then -- If the rank of the player is in the ranks table, set the tag accordingly
                    Speaker:SetExtraData("Tags", {{TagText = tag.TagText, TagColor = tag.TagColor}})
                    Speaker:SetExtraData("NameColor", tag.TagColor) -- Sets the name color of speaker to the tag color
                end

            end   
     
        end

    end

end)

If you could possibly help me that would be appreciated.
Thanks!

2 Likes

I found this explanation quite useful: Chat coding: Working with tags and name colours? - #2 by sircfenner. I was able to get mine working with this method.

3 Likes

I’m still having issues I can’t even get it to work at all when I look at the Developer console no errors show up. So… I have no clue what to do.

Hayo!

Would you mind DMing me your version of the script?

I have had no problems with the script in my game. I’ll double check the code I use and the code I provided to see if I possibly mistyped.

I’d love to help find and fix the issue you’re having.

Thanks!

1 Like

I have a system in one of my games. I am not sure if you have solved the issue yet, but if you have not, feel free to take this version: https://www.roblox.com/library/2937582851/Chat-Titles Note: I did not create this, however I rewrote most of ‘titleModule’.

Also, the chat settings are customized for my game. You can keep them or change them back in ClientChatModules > ChatSettings

All of this goes into Chat.

5 Likes

Hey Coasterteam the script I used there in the quote is the one I used in ServerScriptService using a regular script.

Thank you so much for all your help! This one definitely works for me than some of the others I tried.

1 Like

Glad you found a fix for your issue!

Even though you have a solution, I still took a little time to rework my segment of code for more catch-all possibilities.

--[==[ START VARIABLES ]==]--

local Players = game:GetService("Players")

local ScriptService = game:GetService("ServerScriptService")

local ChatService = require(ScriptService:WaitForChild("ChatServiceRunner").ChatService)

--[==[ END VARIABLES ]==]--

--[==[ START TABLE FOR TAGS ]==]--

--[==[

    FORMAT:

    ["RankInGroup"] = {TagText = "TagTextHere", TagColor = Color3.fromRGB(r, g, b)}

]==]--


-- Here's an example of what a proper rank table could look like

local ranks = {

    ["255"] = {TagText = "Lead Developer", TagColor = Color3.fromRGB(233,30,99)},

    ["250"] = {TagText = "Lead Scripter", TagColor = Color3.fromRGB(230,126,34)},

    ["225"] = {TagText = "Place Developer", TagColor = Color3.fromRGB(230,126,34)},

    ["200"] = {TagText = "Asset Developer", TagColor = Color3.fromRGB(46,204,113)},

    ["150"] = {TagText = "Moderator", TagColor = Color3.fromRGB(32,102,148)},

    ["100"] = {TagText = "Moderator-In-Training", TagColor = Color3.fromRGB(76,188,206)},

}

--[==[ END TABLE FOR TAGS ]==]--

--[==[ GROUP ID ]==]--

local groupId = 0 -- Replace with your own ID

--[==[ GROUP ID ]==]--

function checkPlr(SpeakerName)

    if game.Players:FindFirstChild(SpeakerName) then -- Makes sure the speaker is a real player

        local plr = game.Players:FindFirstChild(SpeakerName) -- Get the player Object

        local UserId = plr.UserId -- Getting the UserId of the speaker

        local Speaker = ChatService:GetSpeaker(SpeakerName) -- Getting the Speaker Object from ChatService

        if plr.UserId == 0 then -- Replace 0 with your own ID

            Speaker:SetExtraData("Tags", {{TagText = "Special Person", TagColor = Color3.fromRGB(241,196,15)}}) -- Customize the text and color to your liking

            Speaker:SetExtraData("NameColor", Color3.fromRGB(241,196,15)) -- Set the name color to the tag color

        elseif plr:IsInGroup(groupId) then -- If player is in the group, check the rank

            local rank = plr:GetRankInGroup(groupId)

            for i,tag in pairs(ranks) do -- Loop through the ranks table

                if i == tostring(rank) then -- If the rank of the player is in the ranks table, set the tag accordingly

                    Speaker:SetExtraData("Tags", {{TagText = tag.TagText, TagColor = tag.TagColor}})

                    Speaker:SetExtraData("NameColor", tag.TagColor) -- Sets the name color of speaker to the tag color

                end

            end

        end

    end

end

if groupId == 0 then

    warn(script:GetFullName() .. ": You must set a groupId to use the tag system!")

end

-- [==[ INIT SYSTEM ]==] --

for _,v in pairs(game:GetService("Players"):GetPlayers()) do -- This is mainly for studio, but a catch-all solution

    checkPlr(v.Name) -- Call the check function

end

ChatService.SpeakerAdded:Connect(function(SpeakerName) -- Wait for a speaker to be added to Chat

    checkPlr(SpeakerName) -- Call the check function

end) 

I found this code to work a lot better than my previously provided code and will be editing my original post with it.

The issue you had with the script relates to how the ChatService system instantiates itself. Your ChatSpeaker was added before the ChatService.SpeakerAdded RBXScriptSignal was connected. Hence no errors being thrown as there was no compiler or runtime error.

Thanks!

2 Likes