How can I filter this custom chat script so that players don't go swearing on my game?
In my game I have a custom chat that I put in that would allow players to talk more freely, but I'm afraid that some players will go abusing this and start swearing at other players or just use fowl language in general, I didn't want to resort to using normal Roblox chat because it filters half the things players say. I tried to look for a way to block specific words on you tube and free models but I didn't find anything. I had looked on the wiki and found FilterStringAsync but It still uses the normal Roblox chat filter. After fiddling with the script I came here for help, I would be very grateful to anyone who can help me, here is the script
01 | function NewLabel(parent, msg, player) |
02 | newchatline = Instance.new( "TextLabel" , parent) |
03 | newchatline.Text = player.Name.. ": " ..msg |
04 | newchatline.Size = UDim 2. new( 1 , 0 , 0 , 15 ) |
05 | newchatline.Position = UDim 2. new( 0 , 0 , 1 ,- 15 ) |
06 | newchatline.Font = "SourceSansBold" |
07 | newchatline.TextColor 3 = Color 3. new( 1 , 1 , 1 ) |
08 | newchatline.TextStrokeTransparency = 0 |
09 | newchatline.BackgroundTransparency = 1 |
10 | newchatline.BorderSizePixel = 0 |
11 | newchatline.FontSize = "Size14" |
12 | newchatline.TextXAlignment = "Left" |
13 | newchatline.TextYAlignment = "Top" |
14 | newchatline.ClipsDescendants = true |
15 | newchatline.Name = "line1" |
18 | function UpdateOldLabels(Parent) |
19 | for i,v in pairs (Parent:GetChildren()) do |
20 | if v.Name:sub( 1 , 4 ):lower() = = "line" then |
21 | local LineNumber = v.Name:sub( 5 ) |
22 | if LineNumber = = "12" then |
25 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
26 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 15 ) |
32 | game:GetService( "Players" ).PlayerAdded:connect( function (player) |
33 | player.Chatted:connect( function (msg) |
34 | for _,v in ipairs (game:GetService( "Players" ):GetChildren()) do |
35 | UpdateOldLabels(v:WaitForChild( "PlayerGui" ).ScreenGui.Frame) |
36 | UpdateOldLabels(game:GetService( "StarterGui" ).ScreenGui.Frame) |
37 | NewLabel(v:WaitForChild( "PlayerGui" ).ScreenGui.Frame, msg, player) |
38 | NewLabel(game:GetService( "StarterGui" ).ScreenGui.Frame, msg, player) |