How could I edit a message in the roblox chat?

I’m trying to edit a message that already was sent to the client, I don’t have a big knowledge about roblox chat system, so can somebody help me or explain me how to do it?

1 Like

You currently can’t edit a message in the roblox chat.

3 Likes

I’m sure that I can, but I just don’t know how

In default Roblox chat, you are unable to edit messages.

However in your own custom chat, you can listen for an event and change the message on the clients.

Client edits message > Sends to server > Server does sanity checks > Send to clients > Clients update the specific message. (Please do filter the edited message - we don’t want your players to send bad things in chat)

Unfortunately you need to create your own chat to do this - so if you don’t know how to do that then look up some tutorials!

1 Like

Yeah as @21stPsalm said you can’t. I think you could like have a system where you can intercept it and change it from there.

There is one way you could do this.
You could most likely hook up a RemoteEvent that fires all clients with the message you want to delete (LayoutOrder) and go through a for loop in the chat gui (this exists in the playergui).

The chat texts are stored in Scroller.
image
This message right here can be edited by changing the TextLabel’s text.
image
image

This would be hard to pull off, which is why I (and many others) would suggest just making your own Chat GUI.

5 Likes

Basically, what I want to do is, create a bot that sends a message like “Wait a moment…” while searching something, and then edit that message to something else. I did the bot and everything, but I don’t know how to edit the message.

In that case, have a look at @zQ86’s post in which it displays the hierarchy. You can run a loop that looks for a specific Speaker/chat message and then update the text box.

1 Like

Hmm interesting, I want to build off this too.

So the method of using a loop totally works fine, but only if one text to be changed is in the chat. It looks like you want the text to be “Wait a moment…”, and I think you’re most likely going to use that as the comparison to distinguish which textlabel you want to change.

So two textlabels texts can’t be the same, otherwise you can’t tell which one to change properly. So I think using a childAdded event listener with a table would help optimization and keeping track of which text’s to alter.

Take a look at Lua Chat System, particular the ‘Chat Workflow’ chapter.

There may be a possibility to make a custom ‘server module’, that will be “recognized and used” by the default chat system.

Also study the usage of the InsertDefaultModules BoolValue - setting this to true, and being at the correct location in the Chat-hierarchy, then the default modules and your custom module should be working alongside each other.

There’s no documentation on how to modify messages. You can’t just figure it out by looking at it.

An easier way than all of this is editing the bubble chat script.
I did this for my realtime translation chat, this should affect both gui and bubble!
Clone the chat script and go to line: 572 in the ChatMain module.
This is where you can edit the message.
In bubble chat is line 619

Just do message = any string value lol
Have a good day, HiddenKaiser

1 Like

@Uralic - If you read/study enough and experiment with the code, then it seems to be quite easy to modify chat messages. - Though to delay messages may take some extra scripting effort.

After having studied a copy of the default chat modules, along with the documentation I linked to previously, I quickly made this, a simple (server-side) ModuleScript that reverses whatever is written into the chat:

-- a ModuleScript placed within Chat / ChatModules
local function Run(ChatService)

	local function ReverseTheChatMsgFilterFunction(speakerName, messageObj, channelName)
		local msgTxt = messageObj.Message
		msgTxt = (msgTxt):reverse()
		messageObj.Message = msgTxt
	end

	ChatService:RegisterFilterMessageFunction("ReverseChatMsg", ReverseTheChatMsgFilterFunction)

end

return Run

RobloxChatWorkspace

2 Likes

While in a sense that covers editing of a chat message, that’s not what OP is asking for, so I don’t entirely think it’s accurate to say that it’s easy. What OP wants to do is modify a message that has already been sent in the chat line from one message to another, not modify the message immediately after being sent one time.

I do not believe this behaviour is natively supported and edits to the Lua Chat System have to be made in order for something like this to be done. Processed messages are sent to the client so server modification wouldn’t mean much unless the client polls/fetches history updates or whatever.

1 Like

Uhm, yeah, I stand corrected, @PostApproval. I didn’t correctly understand OPs actual intentions with his chat bot.

So I took a closer look at the default chat system and documentation, and discovered that each message-object is assigned a numeric ID value. This ID is used within the local-script ChatChannels method UpdateMessageFiltered which can replace a previously already transmitted chat message.

From that discovery, I examined the scripts further, and found that a remote-event OnMessageDoneFiltering is used to send this replacement message-object from server to client(s).

With that knowledge and some experimentation, I figured it is possible to (mis-) use this remote-event, giving it the correct arguments, which would then replace chat messages already sent.

So info to @Xx_XSanderPlayXx, maybe the module-script code here can be of use / inspiration to you, so you don’t have to clone / re-implement the entire chat system again.

Though please still remember to follow Roblox’s ToS / rules, and ensure that message-texts are correctly filtered before transmission.

-- Server-side module-script for the chat-system's `ChatModules` folder
local function Run(ChatService)
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

	-- Found the chat system's remote-events folder, by looking in ChatServiceRunner server-script code
	local EventFolderName = "DefaultChatSystemChatEvents"
	local EventFolder = ReplicatedStorage:FindFirstChild(EventFolderName)
	
	-- The OnMessageDoneFiltering remote-event can be used to make chat's localscript replace a previously sent message.
	local RemoteEventName = "OnMessageDoneFiltering"
	local OnMessageDoneFiltering = (EventFolder and EventFolder:FindFirstChild(RemoteEventName)) or nil
	
	local delayedMessages = {}
	
	local function DelayedMessagesHandler(handlerId)
		while nil ~= script.Parent do
			local nextTime = math.huge
			local i = #delayedMessages
			while i > 0 do
				local delayedMsg = delayedMessages[i]
				if delayedMsg then
					if delayedMsg.delayUntilTime <= os.time() then
						local messageObj = delayedMsg.messageObj
						messageObj.Message = "(Done)... " .. delayedMsg.originalMessageText
						
						OnMessageDoneFiltering:FireAllClients(messageObj, delayedMsg.channelName)

						-- No need for the message anymore.
						table.remove(delayedMessages, i)
					else
						-- Get what the lowest next delay-until-time is
						nextTime = math.min(nextTime, delayedMsg.delayUntilTime)
					end
				end
				i = i - 1
			end
			
			if nextTime < math.huge then
				wait(nextTime - os.time())
			else
				wait(1)
			end
		end
	end
	
	local function DelayedChangeOfMessage(speakerName, messageObj, channelName)
		local secondsToDelayWith = math.random(3,7)
		
		table.insert(delayedMessages, 
			{
				delayUntilTime = os.time() + secondsToDelayWith,
				messageObj = messageObj,
				originalMessageText = messageObj.Message,
				channelName = channelName,
				speakerName = speakerName,
			}
		)

		messageObj.Message = ("Please wait %d secs..."):format(secondsToDelayWith)
	end

	if nil ~= OnMessageDoneFiltering then
		ChatService:RegisterFilterMessageFunction("DelayedChangeOfChatMsg", DelayedChangeOfMessage)
		spawn(DelayedMessagesHandler)
	else
		error("Could not find needed remote-event `" .. RemoteEventName .. "`.")
	end

end

return Run
2 Likes

What I needed was the remote event OnMessageDoneFiltering, thank you <3

1 Like

I’m 2 years late but thanks for this, very easy to make and it works perfectly.