Hello, I’m wondering if there is a way to clear the chat using a script. I have looked at some posts on the Forums; however, what I found was from between 2019-2021 with the old chat system and the code that I found no longer works as the new chat is no longer stored as a ScreenGui inside of PlayerGui in the player.
If anyone has any solutions it would be much appreciated so please do reply if you can
All of the chat commands and methods are now internal and cannot be accessed through normal scripts. You can only use the given APIs to do certain actions now.
From what I’ve seen, there isn’t an exposed API or method that allows you to clear the chat for now. You can only do this with the old chat system.
Would say that this script would work, i did not test it yet, but tell me if it works
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message:lower() == "/clearchat" then
for i = 1, 50 do
game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(" ", "All")
end
end
end)
end)
After a lil bit of time, i made this script, i did not test it tho, but if it does work tell me!
local function clearChat()
local chatService = game:GetService("Chat")
for _, channel in pairs(chatService:GetChannels()) do
channel:Clear()
end
end
clearChat()
It’s alr it would be ideal if roblox has an easier way to clear the chat such as a Clear() function for text chat service. I might post a feature request as I’m sure there’s a few other people experiencing a similar issue.
yeah sorry for kinda stealing your solution but i did come up with it before i saw your message (I have been working with TextChatService recently so i knew), and code examples are really important