Chat tag not removing

Hello! In my game there is a shop where you can buy gear, and chat tags. You can unequip tags and gear so you are not stuck with it. However, I have ran into a slight issue on removing the tag.

This is what happens when it is equipped and then unequipped:
image

Here is my tag script:

game.Players.PlayerAdded:Connect(function(player)
	while true do
		wait(5)
		if (player:FindFirstChild("Tag")) then
			if player.Tag.Value == nil then
				local tags = {
					{
						TagText = player.Tag.Value,
						TagColor = Color3.fromRGB(46, 255, 238)
					}
				}
				local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
				local speaker = nil
				while speaker == nil do
					speaker = ChatService:GetSpeaker(player.Name)
					if speaker ~= nil then break end
					wait(0.01)
				end
				speaker:SetExtraData("Tags")
				speaker:SetExtraData("ChatColor",Color3.fromRGB(255, 255, 255)) 
			else
				local tags = {
					{
						TagText = player.Tag.Value,
						TagColor = Color3.fromRGB(46, 255, 238)
					}
				}
				local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
				local speaker = nil
				while speaker == nil do
					speaker = ChatService:GetSpeaker(player.Name)
					if speaker ~= nil then break end
					wait(0.01)
				end
				speaker:SetExtraData("Tags",tags)
				speaker:SetExtraData("ChatColor",Color3.fromRGB(213, 155, 40)) 
			end
		end
	end
end)

What am I doing wrong? Thanks for any help!

1 Like

This line must have returned a tag without any string in it. Maybe remove it?

Removing that line would keep it the same if they had a tag in the past. I found this post that results with this as an answer:
image

This is what I am doing, so I am unsure what to do.

Probably you are getting a string value if it has a value or not, but I’m not sure if it goes with the else option. Try printing that string or instead of that, use

if player.Tag.Value = "" then
1 Like