Hello,
I am trying out the new TextChatService, so far I’ve created my own UI, and now I need to add the functionality. Unfortunately, TextChatService is really undocumented and I’ve come to an error that I do not know how to fix.
When I execute the following code:
TextChannel:DisplaySystemMessage("This is a message.", "SystemMessage")
These errors come up:
cannot resume non-suspended coroutine
Error occurred while calling TextChannel.OnIncomingMessage: cannot resume non-suspended coroutine
Here is the whole function that is attached to TextChannel.OnIncomingMessage:
local function RecieveMessage(message : TextChatMessage)
if message.Metadata == "" then
if message.Status == Enum.TextChatMessageStatus.Success then
local NewChatMessage = MessageTemplate:Clone()
if message.TextSource then
local colorHex = getColorFromName(message.TextSource.UserId):ToHex()
NewChatMessage.Text = "<font color='#" .. colorHex .. "'>[" .. message.PrefixText .. "]</font>: "..message.Text
NewChatMessage.Parent = MessageTemplate.Parent
NewChatMessage.Visible = true
end
-- THE CODE BELOW IS WHAT ERRORS OUT
elseif message.Status == Enum.TextChatMessageStatus.Floodchecked then
message.TextChannel:DisplaySystemMessage("too many messages", "SystemMessage")
-- THE CODE BELOW IS WHAT ERRORS OUT
elseif message.Status == Enum.TextChatMessageStatus.MessageTooLong then
message.TextChannel:DisplaySystemMessage("long message", "SystemMessage")
end
elseif message.Metadata == "SystemMessage" then
local NewChatMessage = MessageTemplate:Clone()
NewChatMessage.Text = "<font color='rgb(255, 50, 50)'><i>"..message.Text.."</i></font>"
NewChatMessage.Parent = MessageTemplate.Parent
NewChatMessage.Visible = true
end
end
So, does anybody have any clue as to what I am doing wrong here?