Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this chat filter not function?

Asked by
wrenzh 65
10 years ago

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

Log in to vote
0
Answered by 10 years ago
lower = msg:lower()
if msg:match(" " .. v:lower() .. " ") then

I'm assuming you meant:

lower = msg:lower()
if lower:match(" "..v:lower().." ") then
Ad
Log in to vote
0
Answered by
hiccup111 231 Moderation Voter
10 years ago

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

Log in to vote
-1
Answered by 10 years ago

Sorry but I need the full code to understand lol

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. wrenzh 65 — 10y

Answer this question