How to remove a message before replication

Hello, quick question !

Is there a simple way to remove a message before his replication to all clients?

Your post does not have enough details for us to help you. Take note that scripting support is not the place to ask for code nor expect it to come for free. You must attempt it yourself and come back when you run into issues.

Some guide questions to help you:

What is a “message”?
What do you mean by “before replication?”

How should I write my topic?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub ?

Well, I’m not the person that asks for scripts, totally the opposite. I do not have to add something to my post because it’s already enough intuitive.

To answer all of your question :

  • I call a “message” something that a player send in the global chat,
  • I don’t have to explain what is replicating because you clicked on “scripting support”, you should know what I mean.

I guess I will not change something to the conversation if I don’t say anything.

For example, when the player chats, the server verifies the message first before replicating/sending it to the other players.

I kept my post simple and intuitive, there’s no issue and I couldn’t find any documentation on that.

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)

local function SecondaryChatFilter(Sender, Message, Channel)
    if Message == "Hello" then
        return true --marks the sent message as filtered, so it won't be replicated to clients
        return false --makrs the sent message as safe

ChatService:RegisterProcessCommandsFunction("applyExtraFilters", SecondaryChatFilter)

Considering you don’t want script samples and to be spoonfed then I’ll just give you a basic rundown so you can do it yourself.

Replication, (which according to your other post you know what it is) in this case would replicated from the client, to the server, to all other clients.

Client (Local) > Server > All Clients

So it’s simple, stop the original client from ever going to the server to then filter and display your message.

You could do it as @wevetments stated, but truthfully I see that as a workaround rather then an actual solution (as the applyExtraFilters isn’t necessarily meant for that.)

How I’d do it would be to fork the chat system and then go to wherever messages and sent/handled and check the contents of the message, if it’s within your boundaries then you should return and prevent the message from being sent. Alternatively you could change the message content or display a message error to the user.

1 Like

I wouldn’t consider that as a workaround. That literally does a better job than “forking” the chat scripts. One benefit of my method compared to your “forking” is the chat scripts will get updates and won’t remain outdated until you manually update the chat scripts and re-fork the scripts.

Perhaps you’re right that applyExtraFilters is not the right command processor to use, but it most certainly would be an option.

1 Like

I had no idea on how to do it, and the documentation was really inexistant in that domain.

Since I now have the correct service, I’ll find documentation on that.