I have a ChatFilter script that kicks players whenever they say a certain word in the blacklist. Although, this is not the case. Whenever a player joins the game, before they even speak, this error is printed to the output: 'Error occurred, no output from Lua'.
I am not sure what this means, as I have never heard of or even experienced this before. The error occurs on line 7.
local Players = game:GetService("Players") local blacklist = { "the code is", "code", "alpha"; } Players.PlayerChatted:Connect(function(messageType, player, message) for _, blocked in next, blacklist do if string.match(message, blocked) then player:Kick("[ChatFilter] You have said a word or phrase that has caused you to be kicked. You may rejoin.") print("[Kick]"..player.Name.." has been kicked by [ChatFilter].") end end end)
.PlayerChatted isn't a method of Players Service.
Use .Chatted of players.
game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) end) end)
As for the blacklist, you pretty much have it right. I'd just use find, though, tbh.
local blacklist = { "the code is"; "code"; "alpha"; } local function isMsgAllowed(msg) -- functions make things nice (break code into chunks) msg = msg:lower() -- make it lowercase for _,blocked in next, blacklist do if(msg:find(blocked))then return false end end return true end game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) if(not isMsgAllowed(msg))then plr:Kick("MSG") end end) end)