Hello everyone! Recently, I’ve been attempting to implement chat tags into my game.
However, ChatService:GetSpeaker(player.Name)
always returns nil and I don’t understand why that’s happening. I’m using the standard chat system. Nothing has been modified. And it has been ran on studio, in case that changes anything.
Here’s the script I’m using to give tags to the players:
local Players = game:GetService('Players')
local Chat = game:GetService('Chat')
local ChatService = require(Chat:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
Players.PlayerAdded:connect(function(player)
local PlayerPermissions = _G.PermissionsTable[player.UserId]
print(PlayerPermissions)
if PlayerPermissions == nil or PlayerPermissions > 6 or PlayerPermissions < 0 then
PlayerPermissions = 0
_G.PermissionsTable[player.UserId] = 0
end
local speaker
local MaxTries = 5
local Tries = 0
while not speaker do
if Tries < MaxTries then
print("Infinite loop here")
speaker = ChatService:GetSpeaker(player.Name)
wait()
Tries = Tries + 1
else
break
end
end
if speaker.PlayerPermissions > 0 then
speaker:JoinChannel("Staff")
end
if speaker.PlayerPermissions > 3 then
speaker:JoinChannel("Developer")
end
speaker:SetExtraData("Tags", {{ TagText = SpecialTagTable[PlayerPermissions][1], TagColor = SpecialTagTable[PlayerPermissions][2] }})
speaker:SetExtraData("NameColor", SpecialTagTable[PlayerPermissions][2])
end)
Yes, I do know that another post was made about the same behavior. However, it appeared to be caused by a different issue.