I am working on custom admin commands, and I am trying to make the warn command which makes your message appear in bold red text. I already made the bold red text by creating a new chat message but when I try to :Destroy() on the chat message, it does not destroy the original message. How do I remove the original chat message?
Are you using a completely custom chat system, a plugin for Robloxâs chat system, or an external script that interfaces with the chat system? If you are using a chat module you can do this by setting the message color to red whenever a player chats (and is using warn command) using ChatService. RegisterFilterMessageFunction.
If I remember correctly you cannot destroy a chat message using an external script, the only way you can do this is a chat module.
You could make it a bindablefunction so it can be called from a external script
True true but still requires you to modify the chat
So that means thereâs no way to delete a chat message without modifying it
Yes, since unless you modify it, the chat GUI is parented to game.CoreGui.
Why would you use a BindableFunction? As far as I know, there is no reason for the chat system to send anything back to the script upon deleting a message.
Nope, itâs actually parented to PlayerGuis (created by a ModuleScript). Chat system is fully ported to Lua.
Ups, i did a mistake there, didnât notice i said âfunctionâ instead of âeventâ
When a message is created it isnt stored somewhere magical in the roblox universe, its actually âhiddenâ right under your nose in the playergui : D, I forget the exact reference but look into the chat guis until you find the text label representing your message then just destroy that : D
I think youâll want to prevent the chat message from being sent in the first place instead of figuring out how to delete it. For this, you can bring out a bit of the Lua Chat System repository to Studio and add to it so it fits your admin commands. The rest of the scripts will automatically insert themselves.
In the Chat service, insert the following:
Folder ClientChatModules
Folder CommandModules
BoolValue InsertDefaultModules <true>
Once this is done, insert a ModuleScript, your choice of name. The content of the ModuleScript should essentially flow like this:
local util = require(script.Parent:WaitForChild("Util"))
function ProcessMessage(message, ChatWindow, ChatSettings)
end
return {
[util.KEY_COMMAND_PROCESSOR_TYPE] = util.COMPLETED_MESSAGE_PROCESSOR,
[util.KEY_PROCESSOR_FUNCTION] = ProcessMessage
}
You can read up more on that here under Command Modules:
The message doesnât show up, but the admin commands that Iâm using still processes it. How can I make it so that the admin script doesnât process the message?
function ProcessMessage(message, ChatWindow, ChatSettings)
if message == ":kill all" then
return true --don't let the admin commands execute it!
else
return false
end
end
That you will have to edit the admin script itselfâŚ
this may be easier. follow what is in this topic.
The post youâre replying to was made in 2019 and wasnât exactly proper to begin with. This was intended to be a server command module but I think I confused the two because both the client and server have command modules that they can run on chats.
The canonical way to stop a chat from processing is registering a server-side command module that returns true to prevent the message from being processed further. Command modules are the first processes ran on a chat so if you want to stop it preemptively. ShouldDeliver is also a viable solution but since itâs not documented it can be difficult to actually find.
I prefer to use command modules not only because theyâre canonical but because theyâre a good fit with most structures. If you fork the folder without the default modules included you can retain a module-based format. Additionally if you have some use case where itâs useful to hook in and out a function you can do so easily with the API because it also supports unregistry.
RegisterChatCallback is a little more rigid. You canât unregister a callback once itâs been invoked and in my honest opinion itâs less clean when youâre making chat command systems. Depends on how you handle it but chat commands tend to make it easy, idiomatic and consistent. All default chat commands are already implemented as command modules after all.
Easier doesnât necessarily mean better, but ShouldDeliver is also another way to stop a chat from processing, yeah.