Hello there, been trying to debug a system to add chat tags to a player’s name in chat.
This system is attempting to use the module ChatService, but returns an infinite yield, and doesn’t move past this.
I’m unsure as to how to fix this, and have been trying multiple things the past few hours.
Is there a better way to go about this?
task.wait(1)
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local setChatTagEvent = ReplicatedStorage:WaitForChild("SetChatTag")
local playerTags = {}
local function onEventFire(player, tag)
print("SetChatTagServer Debug")
playerTags[player.UserId] = tag
print(player.Name .. " has selected the chat tag: " .. tag)
end
setChatTagEvent.OnServerEvent:Connect(onEventFire)
local function onMessageSent(speaker, messageObject)
local userId = speaker.UserId
if playerTags[userId] then
messageObject.Message = "[" .. playerTags[userId] .. "] " .. messageObject.Message
end
end
ChatService:RegisterProcessCommandsFunction("addTag", onMessageSent)