Hey there!
Today I will be showing you how to make a unique chat tag in roblox!
So first you will need to get the local player who is getting the tag, so type:
local players = game:GetService("Players")
After that you will need to get the chat service by typing:
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
After that you will need to tell roblox what players will get the tags by typing:
local tags = { [PlayersUserIdHere] = {TagText = "TagName", TagColor = Color3.fromRGB(TagColor)}, }
We use the players UserId incase they change their name!
After that you need to detect if someone has spoken in chat by typing:
chatService.SpeakerAdded:Connect(function(playerName)
end)
Then you will need to get the speakers name and the player by typing:
chatService.SpeakerAdded:Connect(function(playerName)
local speaker = chatService:GetSpeaker(playerName)
local player = game.Players[playerName]
end)
Finally, you will need to detect if the player is detected as someone that should have a tag by typing:
if tags[player.UserId] then
speaker:SetExtraData("Tags",{tags[player.UserId]})
Final script:
local players = game:GetService("Players")
local chatService =
require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Admins = {
'PlayerName', 'PlayerName2'
}
local tags = {
[PlayersUserIdHere] = {TagText = "TagName", TagColor = Color3.fromRGB(TagColor)},
}
chatService.SpeakerAdded:Connect(function(playerName)
local speaker = chatService:GetSpeaker(playerName)
local player = game.Players[playerName]
if tags[player.UserId] then
speaker:SetExtraData("Tags",{tags[player.UserId]})
end
end)
I hope this helped!