How do you hide chat messages on the server

I’m making a commands module where everything is fully server-sided (because of hackers/exploiters obviously)

I want to make a system where when you send a command, it hides the message

I have a player.Chatted base because that’s the only reliable server connection in this case

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        local message = msg:split(" ")
        local commandWithPrefix = message[1]
        local usedPrefix
        for _, v in Prefixes do
            if commandWithPrefix:sub(1, 1) == v then
                usedPrefix = v
                break
            end
        end
        if not usedPrefix then return end
        local command = string.lower(commandWithPrefix:split(usedPrefix)[2])
        local foundCommand
        for customCommand, _ in CustomCommands do
            if customCommand:lower() ~= command then continue end
            foundCommand = CustomCommands[customCommand].Function
            break
        end
        for currentCommand, _ in getCommands() do
            if currentCommand:lower() ~= command then continue end
            foundCommand = getCommands()[currentCommand]
            break
        end
        if not foundCommand then return end
        local args = message
        table.remove(args, 1)
        foundCommand(player, args, msg)
    end)
end)
1 Like

This might give you an idea if I understood what you want to do.

I don’t understand how this works but I’ve found something that might work.

I’ve found this at OnServerReceivingMessage but what does it mean by the ‘Message’ object

Probably callback function’s parameter. I’m not home right now but a quick test should show it.

I’ve tried printing it and it printed nothing, absolutely nothing, no errors

I’ve further tested it and found it gets passed by Chat:InvokeChatCallback()

local chat = game:GetService("Chat")

chat:RegisterChatCallback(17, function(message)
    print(message) --> "hello"
end)

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message) --> lets pretend message is "hello"
        chat:InvokeChatCallback(17, message)
    end)
end)
1 Like

Can anyone else help me? I know how to filter messages with server-client communication. Though, I want to keep the module safe to use with no exploit threats.

Edit: Updated Information:

Using this code:

local shouldHideMessage = false
game.Chat:RegisterChatCallback("OnServerReceivingMessage", function(message)
    task.wait()
    return shouldHideMessage
end)

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if Random.new():NextInteger(1, 2) == 1 then --give 50/50 chance of appearing the message lol
            shouldHideMessage = true
        else
            shouldHideMessage = false
        end
    end)
end)

Works great for LegacyChatService.
However, I still want to make it compatible with TextChatService and not just LegacyChatService.

well uh according to my knowledge

roblox didnt add Event on server to recieve messages (at least i tried connecting to events like .MessageRecieved on server but no hope it wasnt fired at all)

If it was that simple, this post wouldn’t even exist.