I’m making some sort of tournament game. I want to integrate a lot of the UI/UX stuff into ROBLOX’s existing core UI. One of the things I want to do is display game state messages (i.e. game is entering intermission, is starting a tournament, etc) in the chat. Currently, I know how I can send system messages to the chat but I also want to avoid spamming the chat with system messages, so ideally I would like to delete previous system messages whenever a new one is posted.
I did something like this for the previous chat system but it was heinously ugly if I recall correctly and I don’t think I have access to the code anymore unfortunately.
I’ve looked over the API and haven’t found any existing methods for doing what I want so I assume I have to make it myself. What is the best way of going about doing this? All I need is a function that either finds the previous system message in chat and removes it or can remove any message from chat given the message’s content.
Dont use TextChatService for this instead use Player.Chatted.
It would look something like this:
local PlayerService : Players = game:GetService("Players")
local function onPlayerAdded(player : Player) -- player handler
local function onChatted(message : string) -- chat handler
end
player.Chatted:Connect(onChatted)
end
for _, player in pairs(PlayerService:GetPlayers()) do onPlayerAdded(player) end
PlayerService.PlayerAdded:Connect(onPlayerAdded)
This doesn’t bring me any closer to my goal. One, the messages I’m sending are from system, not a player, and thus don’t trigger the Chatted event and second, I don’t know how to continue towards my goal of removing a specific message in chat from the code given.
Not sure if this helps but, this is what I have written to at least “hide” a message received on the client.
local Cmds:{string} = {}
TCS.OnIncomingMessage = function(Msg:TextChatMessage)
if table.find(Cmds,Msg.Text:lower()) then
local Properties = Instance.new("TextChatMessageProperties")
Properties.Text = " "
return Properties
end
end
Works in studio at least, haven’t tested in live yet.
Like the only solution, three months ago (in January) when this topic was recent, he could use tables to store the messages that arrive, it would be a little less optimized but it would work.
This is annoying because I have to override the OnIncomingMessage callback, which is invasive if my module is designed for the developer to plop into an experience