How could I make player:Kick require a module for the message?

Solution
In a new module, write some code similar to the following:

local filter = {}
function filter:getprocessedwords()
	local list = {
		"stealthied"	
	}
	return list
end
return filter

Then in the original function that identifies these words, define the module and then give the variable bannedWords the array that filter:getprocessedwords() returns.

local filter = require(game:GetService("ServerScriptService").Module)
game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		msg = msg:lower()
		local bannedWords = filter:getprocessedwords()
		for _, phrase in ipairs(bannedWords) do
			if (msg:find(phrase) ~= nil) then
				player:Kick("REMO AutoMod Violation | You've been removed from this game for communicating a word commonly associated with admin abuse.")
			end
		end
	end)
end)

You can include a lot more details to return, although this barebones method should indeed work. I’m pretty sure you don’t even have to use a function and could simply just have the module return list right off the bat, although it’s a lot more efficient and easier to edit to use a function for this.

2 Likes