Issue with chat tags

I’m currently trying to make it so you can equip chat tags that you own, I’m able to equip the VIP chat tag but nothing else, it’s not throwing an error, does anyone know why?

–ServerScriptService script

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local mps = game:GetService("MarketplaceService")

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local repStor = game:GetService("ReplicatedStorage")

local chatTagEvent = repStor:WaitForChild("ShopConfigs").PlayerOwnsVIP

chatTagEvent.OnServerEvent:Connect(function(player, text, color)
	if text == "VIP" then
		if mps:UserOwnsGamePassAsync(player.UserId, 25601856) then
			local tags = {
			TagText = text
			}
			local speaker = chatService:GetSpeaker(player.Name)
			speaker:SetExtraData("Tags", {{TagText = text}})

			speaker:SetExtraData("ChatColor", color)
		elseif text == "MEMBER" then
			if player:IsInGroup(7425784) then
				local tags = {
					TagText = text
				}
				local speaker = chatService:GetSpeaker(player.Name)
				speaker:SetExtraData("Tags", {{TagText = text}})

				speaker:SetExtraData("ChatColor", color)
			elseif text == "EPIC" then
				if player.BackpackItems.EpicChatTag.Value == true then
					local tags = {
						TagText = text
					}
					local speaker = chatService:GetSpeaker(player.Name)
					speaker:SetExtraData("Tags", {{TagText = text}})

					speaker:SetExtraData("ChatColor", color)
				end
			end
		end
	end
end)

–LocalScript in textbutton

local player = game:GetService("Players").LocalPlayer
local repStor = game:GetService("ReplicatedStorage")

local tagEvent = repStor:WaitForChild("ShopConfigs"):WaitForChild("PlayerOwnsVIP")

local equipText = player.PlayerGui.MainUI.TagInventoryFrame.MemberTag.Equip

local function promptError(text)
	equipText.TextColor3 = Color3.fromRGB(255,0,0)
	equipText.Text = text
	wait(2)
	equipText.TextColor3 = Color3.fromRGB(255,255,255)
	equipText.Text = "EQUIP"
end

local function promptSuccess(text)
	equipText.TextColor3 = Color3.fromRGB(0,255,0)
	equipText.Text = "SUCCESS"
	wait(2)
	equipText.TextColor3 = Color3.fromRGB(255, 255, 255)
	equipText.Text = "EQUIP"
end

script.Parent.MouseButton1Click:Connect(function()
	if player:IsInGroup(7425784) then
		tagEvent:FireServer("MEMBER", Color3.fromRGB(76, 255, 0))
	else
		promptError("You are not a member of the group")
	end
end)```

In the server script, only the VIP tag would work, as you have an if statement inside the VIP text checker.
Add an end in front of each elseif statement, as the cause is you not closing the statements correctly.

Instead the script should look like this:

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local mps = game:GetService("MarketplaceService")

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local repStor = game:GetService("ReplicatedStorage")

local chatTagEvent = repStor:WaitForChild("ShopConfigs").PlayerOwnsVIP

local function changeTag(player, text, color)
	local tags = {
		TagText = text
	}
	local speaker = chatService:GetSpeaker(player.Name)
	speaker:SetExtraData("Tags", {{TagText = text}})

	speaker:SetExtraData("ChatColor", color)
end

chatTagEvent.OnServerEvent:Connect(function(player, text, color) -- remove the color parameter, this is exploitable
	if text == "VIP" then
		if mps:UserOwnsGamePassAsync(player.UserId, 25601856) then
			changeTag(player, text, color) -- edit the color, this is exploitable
		end
	elseif text == "MEMBER" then
		if player:IsInGroup(7425784) then
			changeTag(player, text, Color3.fromRGB(76, 255, 0))
		end
	elseif text == "EPIC" then
		if player.BackpackItems.EpicChatTag.Value == true then
			changeTag(player, text, color) -- edit the color, this is exploitable
		end
	end
end)

Note, I suggest you do not determine the color of the tag client-sidedly, as an exploiter could change this and make their tag for example a rainbow and note the client is only checking if the Member tag works, not the other tags.

1 Like

Thank you so much, this works, but now there’s a new issue, all of the tag colors are purple, not the color they are meant to be, do you know why? I’ve done it like this:

changeTag(player, text, Color3.fromRGB(255, 247, 0))```

I assume it is because you put that in every changeTag function, instead of only one.
Else it might have to do with not testing it properly.

Please paste your code in your post.

1 Like

Here’s the whole code:

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local mps = game:GetService("MarketplaceService")

local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local repStor = game:GetService("ReplicatedStorage")

local chatTagEvent = repStor:WaitForChild("ShopConfigs").PlayerOwnsVIP

local function changeTag(player, text, color)
	local tags = {
		TagText = text
	}
	local speaker = chatService:GetSpeaker(player.Name)
	speaker:SetExtraData("Tags", {{TagText = text}})

	speaker:SetExtraData("ChatColor", color)
end

chatTagEvent.OnServerEvent:Connect(function(player, text)
	if text == "VIP" then
		if mps:UserOwnsGamePassAsync(player.UserId, 25601856) then
			changeTag(player, text, Color3.fromRGB(255, 247, 0))
		end
	elseif text == "MEMBER" then
		if player:IsInGroup(7425784) then
			changeTag(player, text, Color3.fromRGB(76, 255, 0))
		end
	elseif text == "EPIC" then
		if player.BackpackItems.EpicChatTag.Value == true then
			changeTag(player, text, Color3.fromRGB(0, 255, 255)) 
		end
	end
end)

I think it has to do with setting the ChatColor instead of TagColor,
the table should be: {TagText = text, TagColor = color} and setting the ChatColor should eb removed.

This should fix the color of the tag, though this would remove the chat color.

Note you can add multiple tags together like so:

{
   {TagText = "EPIC", TagColor = Color3.fromRGB(0, 255, 255)},
   {TagText = "MEMBER", TagColor = Color3.fromRGB(76, 255, 0) },
}
1 Like

I haven’t really checked this thread thoroughly yet but if this is referring to chat color I believe you are restricted to 4 colors, and they use the ChatColor enumaration values instead of Color3 values.

1 Like