I have a Custom Chat GUI but the banned words do not work and I have no idea why below is be script and everything else works fine but the part that stops players saying banned words does not work, why is this?
MAIN SCRIPT:
ChatColors = {"Bright blue","Bright red","Bright green","Bright yellow","Bright orange","Bright violet","White","Black","Pink","Brown"} BannedWords = {"RUDEWORD"} -- Words players cannot use in the chat. CustomColor = 159775970 -- The ID of the item needed to change their own custom chat color. OPrefix = "[OWNER]" -- Prefix used before an owner's name then message. Owners = {"OWNER","OWNER","OWNER"} -- Players who have the owner prefix. APrefix = "[ADMIN]" -- Prefix used before an admin's name then message. Admins = {"ADMIN","ADMIN","ADMIN"} -- Players who have the admin prefix. game.Players.PlayerAdded:connect(function(player) local SV = Instance.new("StringValue") SV.Name = "SetColor" SV.Value = ChatColors[math.random(1,#ChatColors)] player.Chatted:connect(function(message) if string.sub(message:lower(),1,3) == "/c " then if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,CustomColor) then SV.Value = string.sub(message,4) end end for i,a in pairs(game.Players:GetChildren()) do b = a:FindFirstChild("PlayerGui"):FindFirstChild("CustomChat") for i,c in pairs(b.ChatBox:GetChildren()) do if c:IsA("TextLabel") then c.Position = c.Position - UDim2.new(0,0,0.2,0) if c.AbsolutePosition.Y <= 0 then c:Destroy() end end end local d = game.ReplicatedStorage.Chat:Clone() d.Parent = b.ChatBox for i,v in pairs(BannedWords) do if message:lower():find(v) then d.Text = ""..player.Name.." tried to say a banned word!" break end end if d.Text ~= ""..player.Name.." tried to say a banned word!" then for i,x in pairs(Owners) do if player.Name:lower():find(x:lower()) then d.Text = ""..OPrefix.." "..player.Name..": "..message else for i,y in pairs(Admins) do if player.Name:lower():find(y:lower()) then d.Text = ""..APrefix.." "..player.Name..": "..message end end end end if d.Text ~= ""..OPrefix.." "..player.Name..": "..message and d.Text ~= ""..APrefix.." "..player.Name..": "..message then d.Text = ""..player.Name..": "..message end end d.TextColor3 = BrickColor.new(SV.Value).Color game.Debris:AddItem(d,30) end end) end)
BROKEN PART:
for i,v in pairs(BannedWords) do if message:lower():find(v) then d.Text = ""..player.Name.." tried to say a banned word!" break end end
You need to make the value of v
lower case as you have made the message the player has chatted lower case too. Try this:
for i,v in pairs(BannedWords) do if message:lower():find(v:lower()) then d.Text = ""..player.Name.." tried to say a banned word!" break end end