No message property even though there should be it, how would I get the message's content?

I’m following the documentation from here and it says that there should be a message property in the ChatMessage object, but after when I looped through all the properties of said object, no property was named Message. How would I get the message’s content if I can’t find where the message property is? This is my code at the current moment

require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService")):GetChannel(_G.adminConfiguration.channelName).MessagePosted:Connect(function(messageObject)
	for i,v in pairs(messageObject) do
		print("Index: " .. tostring(i) .. "\nValue: " .. tostring(v) .. "\n")
	end
end)

This is the output of a message

what are you trying to attempt with this?

To listen to messages in a certain channel, that’s what…

I would use the Chatted event to check when a chat is sent. Then one of the arguments will be the message, so it will be a lot more simple.

Chatted doesn’t give me enough information, besides, I want to limit what channel people can use the commands in

What happens when you print(messageObject.Message) ? Does it give an error?

Nope, it just says it’s nil, even though you can see that isFiltered is false

I found this, I think its the same problem.

I’m going to see if I can implement .Chatted in the event for myself to get the message’s content

Nope, did not work at all

Please stop bumping your thread. The DevForum rules have a provision against bumping threads.

MessagePosted is a little strange. If you dig into the ChatChannel code, you’ll find that the Message index is actually removed from the MessageObject after it invokes the OnServerReceivingMessage chat callback before being passed around in code.

You will have to resolve this by forking or finding another way to execute your system. In terms of forking, you will need to fork ChatServiceRunner and then modify ChatChannel. You can either stop the message from being removed (might be dangerous) or substitute the message back in:

local success, err = pcall(function()
    messageObj.Message = message
    self.eMessagePosted:Fire(messageObj)
end)

In terms of other methods, try seeing if working with the ChatSpeaker instead would work.

1 Like

I was just trying to get help

I wonder why it’s documented then

I’ll trying to do that, I see that there’s a ‘SaidMessage’ event, so I could use that

You still shouldn’t be bumping threads either way.

MessagePosted, despite its strange behaviour, still does exactly as intended: it’s a signal meant to fire when a message is posted to the current channel containing a ChatMessage object holding data for the sent message. My best assumption here is that there was a small oversight that was not touched on.