Can you delete a chat message?

Hello! I was wondering if there is a way to “:Destroy()” a chat message? Basically I want it so that if a player types in an admin command in the chat and doesn’t have admin, that message is deleted so that other players don’t see the command and start spamming the chat. I already have the notification set to say “You don’t have permissions” but I just need to know how to destroy their message. Thanks! :slight_smile:

1 Like

Not sure if it’s possible but you could maybe find something in StarterGui | Documentation - Roblox Creator Hub or other core gui functions. Other ways are a custom chat or just using the preset /e which won’t even show the message.

1 Like

It’s not possible to delete a message from the chat without exploiting or doing so but with large performance repercussions and unexpected bugs, the function you’re looking for is ChatService:RegisterProcessCommandsFunction(), where you pass a function where you can validate if it’s a command to be displayed in chat or not, based on a boolean return.

Refer to the Roblox example which actually is based off admin commands.
Have fun!

3 Likes

There actually is a way to delete the message, but i need to find how to do it.

The frame thats selected is the message in chat.
You can make a script that checks if the message text is the command. and if it is then :Destroy it.
image

I dont think itll work but I havent tried it.

You currently cannot delete chat messages by default, but if you wish to add that feature into your game it can easily be scripted.

I’ve made a couple of posts regarding “deleting” chat messages. What you actually want to do here is stop the message from being sent at all to any chat processor. Tritative answered this already; if you need extra resources, you can check out some other posts I’ve made on this topic:

https://devforum.roblox.com/search?q=delete%20chat%20%40colbert2677
(Also, please search before posting!)

There is an API method for deleting chat messages but it’s only for the most recent chat message sent, it doesn’t target specific messages and is therefore useless. Stopping the message from sending is your best bet, not trying to hack together a way to delete specific messages from the chat.

2 Likes