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

How Can I Filter Swear Words in this Custom Chat GUI That I Made?

Asked by
8391ice 91
7 years ago

I want to ensure that the game I make is as friendly as possible for people of all ages, and to do so I need to stop people from swearing in this custom chat GUI I made. I think what I would need to do is just create a table filled with all of the possible swear words someone could say and make some kind of function that automatically censors what someone says if it included one of those words, but how could I do that? I've looked all over the ROBLOX wiki for a function that scans through a string to find a word and I can't find one that does. How exactly could I make this happen?

The way my chat GUI works is a folder is in the Workspace and whenever someone chats, a StringValue is created with the name and message of that chatmessage and places in the folder. In a LocalScript inside the StarterGui, which is the one below, a function is triggered whenever a child is added to that folder, and then it'll spit out the message.

local cb1 = script.Parent.cb1
local cb2 = script.Parent.cb2
local cb3 = script.Parent.cb3
local cb4 = script.Parent.cb4
local cb5 = script.Parent.cb5
local cb6 = script.Parent.cb6
local cb7 = script.Parent.cb7
local cb8 = script.Parent.cb8
badWords = {"censored", "bleep"} --In my actual script, there are bad words here, but I took them out. I'm sure it's obvious why :P How can I make it so that the script will scan a message to look for any words that are included here? If there is a way, I could make it so that the result is.. chat.Name.. ": [CENSORED]"

game.Workspace.ChatStorage.ChildAdded:connect(function(chat) --Whenever a new object is added to the ChatFolder in the workspace, this fires.
    cb1.Text = cb2.Text -Basically, what this is doing is moving all of the texts up. There are 8 chatboxes.
    cb2.Text = cb3.Text
    cb3.Text = cb4.Text
    cb4.Text = cb5.Text
    cb5.Text = cb6.Text
    cb6.Text = cb7.Text
    cb7.Text = cb8.Text
    if chat.Name == "8391ice" then --If it's my name, I get a fancy Owner tag :P
        if #(chat.Value) > 122 then --This is to make sure nobody exceeds the character limit.
            cb8.Text = "[Owner] 8391ice:"
        else
            cb8.Text = "[Owner] 8391ice: " ..chat.Value
        end
    else
        if #(chat.Value) > 122 then
            cb8.Text = chat.Name.. ":"
        else
            cb8.Text = chat.Name.. ": " ..chat.Value
        end
    end
    cb1.TextColor3 = cb2.TextColor3 --This moves all of the colors up to correspond with the messages that were moved up.
    cb2.TextColor3 = cb3.TextColor3
    cb3.TextColor3 = cb4.TextColor3
    cb4.TextColor3 = cb5.TextColor3
    cb5.TextColor3 = cb6.TextColor3
    cb6.TextColor3 = cb7.TextColor3
    cb7.TextColor3 = cb8.TextColor3
    if chat.Name == "8391ice" then
        cb8.TextColor3 = Color3.new(1, 0, 0) --I also get a nice red text color :D
    else
        cb8.TextColor3 = Color3.new(1, 1, 1) --Others get a plain white one.
    end
end)

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago

ROBLOX has an official policy regarding this. This Wiki article gives an example of how to make custom GUI.

The important function to take advantage of is FilterStringAsync.

You shouldn't define your own filter (even if you dislike ROBLOX's) because your game will eventually be moderated if it doesn't meet the standards of ROBLOX's.

0
Oh geez I didn't know ROBLOX has a policy regarding this! Thank you so much! You just saved my game from getting banned, LOL! 8391ice 91 — 7y
Ad

Answer this question