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

Why does this chat filter not function?

There are no errors, but it just plain doesn't work.

This is the main code:

_G.Censored = {
	-- censored words
}

_G.MatchChat = function(msg)
	if type(msg) ~= "string" then msg = "" end
	for _, v in pairs(_G.Censored) do
		lower = msg:lower()
		if msg:match(" " .. v:lower() .. " ") then
			return true
		end
	end
end

There are some words in the table, but obviously they aren't appropriate.

Then I call the function MatchChat in the main chat script here:

child.Chatted:connect(function (msg)
	if not _G.MatchChat(msg) then
		-- updating chat GUI. Removed to make it easier to see the code
	end
	end) 
end)

There are absolutely no errors being returned anywhere, and it still doesn't work. I'm at my wit's end, so I came here for help.

3 answers

✓ Accepted answer
lower = msg:lower()
if msg:match(" " .. v:lower() .. " ") then

I'm assuming you meant:

lower = msg:lower()
if lower:match(" "..v:lower().." ") then

Are these both the same type of script?

The reason I ask, because you cannot get the _G. of a LocalScript, from a Server (normal) Script, and vice-versa...

Put the Censor in a ModuleScript. in ReplicatedStorage

Sorry but I need the full code to understand lol

1 comment

0

This is the full code - that is the function that matches to the table and the actual updating of the Chat GUI works fine.

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