How Can I Filter Swear Words in this Custom Chat GUI That I Made?
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.
01 | local cb 1 = script.Parent.cb 1 |
02 | local cb 2 = script.Parent.cb 2 |
03 | local cb 3 = script.Parent.cb 3 |
04 | local cb 4 = script.Parent.cb 4 |
05 | local cb 5 = script.Parent.cb 5 |
06 | local cb 6 = script.Parent.cb 6 |
07 | local cb 7 = script.Parent.cb 7 |
08 | local cb 8 = script.Parent.cb 8 |
09 | badWords = { "censored" , "bleep" } |
11 | game.Workspace.ChatStorage.ChildAdded:connect( function (chat) |
12 | cb 1. Text = cb 2. Text -Basically, what this is doing is moving all of the texts up. There are 8 chatboxes. |
19 | if chat.Name = = "8391ice" then |
20 | if #(chat.Value) > 122 then |
21 | cb 8. Text = "[Owner] 8391ice:" |
23 | cb 8. Text = "[Owner] 8391ice: " ..chat.Value |
26 | if #(chat.Value) > 122 then |
27 | cb 8. Text = chat.Name.. ":" |
29 | cb 8. Text = chat.Name.. ": " ..chat.Value |
32 | cb 1. TextColor 3 = cb 2. TextColor 3 |
33 | cb 2. TextColor 3 = cb 3. TextColor 3 |
34 | cb 3. TextColor 3 = cb 4. TextColor 3 |
35 | cb 4. TextColor 3 = cb 5. TextColor 3 |
36 | cb 5. TextColor 3 = cb 6. TextColor 3 |
37 | cb 6. TextColor 3 = cb 7. TextColor 3 |
38 | cb 7. TextColor 3 = cb 8. TextColor 3 |
39 | if chat.Name = = "8391ice" then |
40 | cb 8. TextColor 3 = Color 3. new( 1 , 0 , 0 ) |
42 | cb 8. TextColor 3 = Color 3. new( 1 , 1 , 1 ) |