The chat tags script doesn't work and it doesn't print out any errors

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a chat tags shop where you can buy certain chat tags where they appear at your chat tag.
  2. What is the issue? Include screenshots / videos if possible!
    It doesn’t give me the chat tag when buying it. Even after a successful data save and a rejoin.
    Here is the buy script
local Cost = 100
local ChatTagColor = "123,255,0"
local ChatTag = "Cool"
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	if plr:WaitForChild("leaderstats").Coins.Value >= Cost and plr:WaitForChild("SecretFolder").ChatTag.Value ~= ChatTag then
		game.ReplicatedStorage.BuyEvent:FireServer(Cost,ChatTag,ChatTagColor)
		script.Parent.Text = "Equipped"
	elseif plr:WaitForChild("leaderstats").Coins.Value < Cost then
		script.Parent.Text = "Not enough coins!"
	elseif plr:WaitForChild("SecretFolder").ChatTag.Value == ChatTag then
		script.Parent.Text = "You already have it equipped!"
	end
end)

Here is the script that responds the remote event

game.ReplicatedStorage.BuyEvent.OnServerEvent:Connect(function(plr,Cost,ChatTag,ChatTagColor)
	plr.leaderstats.Coins.Value -= Cost
	plr.SecretFolder.ChatTag.Value = ChatTag
	plr.SecretFolder.ChatTagColor.Value = ChatTagColor
end)

And here is the script that sets your chat tag

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService("Players")
local Admin = {'Admin here'}
local LeadDev = {'Lead developer here'}


ChatService.SpeakerAdded:Connect(function(PlrName)
	local Speaker = ChatService:GetSpeaker(PlrName)

	for _,v in pairs(game.Players:GetPlayers()) do
		if Players[PlrName].Name == v and Players[PlrName]:WaitForChild("SecretFolder").ChatTag ~= "" then
			local ColorData = Players[PlrName]:WaitForChild("SecretFolder").ChatTagColor
			ColorData = string.split(ColorData,",")
			Speaker:SetExtraData('Tags', {{TagText = Players[PlrName]:WaitForChild("SecretFolder").ChatTag, TagColor = Color3.fromRGB(tonumber(ColorData[1]),tonumber(ColorData[2]),tonumber(ColorData[3]))}})	
		end
	end
end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I can’t find the solution here.

Instead of using ChatService.SpeakerAdded why not use the Player.Chatted function and set the user’s chat tag data that way? the SpeakerAdded function only works upon joining I’m pretty sure.

Then how can i set the chat tag data using Player.Chatted function?

In a similar matter, only using the Player.Chatted function. You can read up on said function here

Edit:

You have not included a .Value to your ChatTag value either.

I don’t think you understand what i am doing here. I am trying to make it so that there is a text (or what i call chat tags) next to your username in chat

I know exactly what you’re talking about, set the same data but set the data every time the user(s) chat.

But how would i get the speaker then?

I’ll type you a template, hold on.

Edit:

local CS = require(game.ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function()
		local Sp = CS:GetSpeaker(player.Name)
		Sp:SetExtraData("Tags", {{TagText = "Tag", TagColor = Color3.fromRGB(0, 0, 0)}})
	end)
end)

Something as simple as this should work for Chat tag setting, implement your current data and you’ll be golden.

1 Like

Just tried it in this way

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService("Players")
local LeadDev = {'zaydoudou'}


game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function()
		local PlrName = plr.Name
		local Speaker = ChatService:GetSpeaker(PlrName)
		for _,v in pairs(LeadDev) do
			if Players[PlrName].Name == v then
				Speaker:SetExtraData('Tags', {{TagText = "Lead dev", TagColor = Color3.fromRGB(255,0,0)}})
			end
		end
	end)
end)

But it didn’t work.
Is there any issue here?

try changing this portion to just plr, also I apologize for the extremely late reply.

if that doesn’t work, try removing the loop and just make a statement to check the table like:

if table.find(LeadDev,plr.Name) then
    Speaker:SetExtraData('Tags', {{TagText = "Lead dev", TagColor = Color3.fromRGB(255,0,0)}})
end