You should really start to switch now. It’s getting removed soon.
Make a RemoteEvent inside of ReplicatedStorage. Call it “ToggleChatTag”.
Make a ScreenGui in StarterGui. Then, add a TextButton or ImageButton inside of it.
After that, add a LocalScript into the button.
Insert this code into it.
local RemoteEvent = game:GetService("ReplicatedStorage").ToggleChatTag
local toggled = false
script.Parent.MouseButton1Click:Connect(function()
toggled = not toggled
RemoteEvent:FireServer("BIG FAN", toggled) -- replace "BIG FAN" with your tag text
end)
This is the client part done. It sends an event over whenever the player wants the chat tag.
Now, we need to make the server-side give the player the tag.
We also need to verify if it is a tag that is toggleable.
To do this, add a normal Script into ServerScriptService.
Here is the code that will make it work:
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local RemoteEvent = game:GetService("ReplicatedStorage").ToggleChatTag
local ToggleableTags = {
"BIG FAN"
}
local function CheckTableEquality(t1,t2)
for i,v in next, t1 do if t2[i]~=v then return false end end
for i,v in next, t2 do if t1[i]~=v then return false end end
return true
end
RemoteEvent.OnServerEvent:Connect(function(plr, name, enabled)
if table.find(ToggleableTags, name) then
local speaker = ChatService:GetSpeaker(plr.Name)
local tags = speaker.ExtraData.Tags
local tag = {TagText = name, TagColor = Color3.fromRGB(255, 255, 255)}
if enabled then
table.insert(tags, tag)
speaker:SetExtraData("Tags", tags)
else
for i,v in pairs(tags) do
if CheckTableEquality(v, tag) == true then
table.remove(tags, i)
break
end
end
speaker:SetExtraData("Tags", tags)
end
end
end)
The CheckTableEquality function was taken from here.
The ChatService is what lets you add chat tags on Legacy Chat.
Whenever a player fires the remote event, we check if the tag is toggleable. This is to stop exploiters from adding their own tags.
If it is found, we get the player’s old tags.
Then, if we want it to be on, we add the tag onto that list and apply it.
If we want it to be off, we remove it from the list and apply the list.
This is very different in TextChatService.
This does not support colours, although I can help you add that as it is quite easy to do.