I want every player with the role “dev” in my Roblox group have the chat tag “dev”, for example.
The problem is, every single tutorial and Forum post I’ve found is made for LegacyChatService. My game uses the TextChatService and I wanna keep it that way, but have the chat tags as well.
Here is the script I currently use which is meant for LegacyChatService:
local group_id = 35257880
game.Players.PlayerAdded:Connect(function(player)
if player:IsInGroup(group_id) then
local tags = {
{
TagText = (player:GetRoleInGroup(group_id)),
TagColor = Color3.fromRGB(255, 125, 0)
}
}
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
task.wait(0.01)
end
speaker:SetExtraData("Tags",tags)
speaker:SetExtraData("ChatColor",Color3.fromRGB(255, 175, 50))
end
end)
Any help would be really appreciated as I’m already late with this update in my game.
For chat tags with TextChatService, you need to return a TextChatMessageProperties instance from TextChatService.OnIncomingMessage. You could set an attribute on the server to show their rank in group.
--server
local reference = {"Owner", "Developer", "Member"}
local rank = player:GetRankInGroup(groupId) --this returns the rank number of their rank
player:SetAttribute("grprank", reference)
--now to the client
local tcs = game:GetService("TextChatService")
local players = game:GetService("Players")
tcs.OnIncomingMessage = function(msg: TextChatMessage): TextChatMessageProperties
--create the properties
local prop = Instance.new("TextChatMessageProperties")
--check for player
local player = msg.TextSource and players:GetPlayerByUserId(message.TextSource.UserId)
if player then
--retrieve rank
local rank = player:GetAttribute("grprank")
--now, you can modify prop.PrefixText, prop.Text using this if you want
end
return prop --return the properties for the message
end