Prevent messages from being sent in chat

Hello, I want to know how to prevent messages from being sent in chat, these will be specific words for certain people. I’ve looked at a few things but they wouldn’t work in my case.

For context, I am making chat admin commands. It uses .Chatted function if the player is an admin (server sided)

Here’s a little tutorial on hiding messages, it might require some modifications to work with your system. If you have any other questions, please let me know!

Create a Script in ServerScriptService with this code:
script.HideCommands.Parent = game:GetService("Chat"):WaitForChild("ChatModules")

Create a ModuleScript named “HideCommands” inside the Script with this code:

local Players = game:GetService("Players")

local prefix = "/"
local commands = {"kick", "view", "bring"} -- You can import your commands here

return function (ChatService)
	local function hideMessage(speakerName, message, channelName)
		message = string.lower(message)
		
		for _, command in commands do			
			if string.sub(message, #prefix + 1, #prefix + #command) == string.lower(command) then
				return true
			end
		end

		return false
	end

	ChatService:RegisterProcessCommandsFunction("hideMessage", hideMessage)
end
2 Likes