But, as this function is only called when a new speaker is added, the rank value stays static even when it updates in-game.
I’ve considered adding a SentMessage function and adding the rank each time a message is sent but this seems unnecessary. I’ve also tried adding a simple .Changed() function into the NewSpeaker function, but then the whole chat breaks. (lol)
Does anyone have any experience adding dynamic tags to the chat who could solve this problem? Thanks in advance!
You don’t need to edit that module. You can use the ChatService api’s function SetExtraData to dynamically assign tags to players.
Example:
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Admins = {
mario118118 = true
}
game.Players.PlayerAdded:Connect(function(plr)
if Admins[plr.Name] then
ChatService:GetSpeaker(plr.Name):SetExtraData("Tags", {{TagText = "Admin", TagColor = Color3.new(1,0,0)}})
end
end
NewSpeaker is responsible for creating a Speaker object within the ChatService. A Speaker represents a player or an added speaker to send messages in the chat. Therefore, you would also need to fetch the Speaker to act upon it. NewSpeaker creates a Speaker and returns the Speaker, so conversely to edit the Speaker again you’d need to fetch it.
You’re probably looking to use the ChatService module to get speakers. It supports a GetSpeaker method. Once you have the Speaker (ChatSpeaker), see the ChatSpeaker module. Supports the methods you’re looking for. Ideally when a player’s rank updates, I’d assume all you need to do is set the extra data for the Speaker.
SetExtraData is not a valid method of ChatService. See my response above. ChatService can be used to fetch speakers and the methods of ChatSpeaker are used to set the extra data of a Speaker.
It’s not. That’s a misleading answer to provide. Extra data functions are not associated with the ChatService, depending on your context - whether you’re referring to the raw Chat service or the ChatService module intended to assist in facilitating functions for the Lua Chat System to external code.
The code sample you provided is a perfectly viable answer but I’d caution you against doing that in the instance that a nil Speaker is returned, which would consequently throw an error for attempting to operate on a nil value and terminate the thread. You should always verify that the return value from a callback is valid before operating on it.
This is a response I had to an older thread from a few months ago, and OP seemed to find it useful. You’ll find the ability to add Chat titles for users that hold a certain rank in the group on Line 197 of ExtraDataInitializer, which is inside the open sourced model I linked on this response:
You provided that code so the least you could do is not make such code present a potential edge case. Furthermore, I’m not “nitpicking” naming. There are times when distinction is important to know because it can cause confusion or misconception in the future. The locations of methods is not the same as nitpicking naming. Please DM me if you have issues with my posts.