Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script to prevent a message from being sent is not working. Any ideas?

Hello. As my Questions states, I am attempting to create a script that prevents a message from being sent.

local Chat = game:GetService("Chat")
local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
local ChatSettings = require(ReplicatedModules:WaitForChild("ChatSettings"))
local ChatConstants = require(ReplicatedModules:WaitForChild("ChatConstants"))

local ChatLocalization = nil
pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization) end)
if ChatLocalization == nil then ChatLocalization = {} end

if not ChatLocalization.FormatMessageToSend or not ChatLocalization.LocalizeFormattedMessage then
	function ChatLocalization:FormatMessageToSend(key,default) return default end
end

local function Run(ChatService)

	local function ProcessCommandsFunction(fromSpeaker, message, channel)
		if (message:lower() == "bread") then
			print("message")
			return true -- People say that this is what deletes the message.
		end
	end
end


return Run

The script is inside ChatModules, which is inside Chat.

However, when I type in "bread" into chat, it will not delete. Any ideas why?

Thanks, LennyPlayzYT

2 comments

0

i have never used chat but by looking at you ProcessCommandsFunction function, you don't seem to be connecting it anywhere, is that supposed to be?

0

oh yea, he doesn't connects it anywhere

1 answer

In game.Chat.ChatModules.ChatMessageValidator, there's a function called Run. Add in there somewhere:

if message:lower() == "bread" then return true end

My bad, accidentally wrote false instead of true.

This discussion is preserved as it was. New answers, comments, and votes are closed.