^ Title says it all. Here's my code:

-- Script in "ServerScriptService"
game:service("ReplicatedStorage").FilterText.OnServerInvoke = function(p,grab)
	print('grabbing filter restraints')
	return game.Chat:FilterStringForBroadcast(grab,p)
end
-- Descendants function
wait(5)
function FilterString(str)
	if not pcall(function()
	local filtered = game.Chat:FilterStringForBroadcast(str,game.Players:children()[1]) -- This line is stupid and inefficient, I know. I'm still new to Chat:Filter...
	if filtered ~= nil then
	return filtered
	else
	return "< Filter Failed >"
	end
	end) then
	return "< Filter Failed >"
	end
	return "< Filter Failed >"
end
local sources = {
	"Players",
	"Workspace",
	"Lighting",
	"ReplicatedStorage",
	"ReplicatedFirst",
	"ServerStorage",
	"ServerScriptService",
	"StarterGui",
	"Teams",
	"StarterPack",
	"StarterPlayer",
	"SoundService",
	"Chat",
	"TestService",
	"LogService",
	"TeleportService"
}
for i=1,#sources do
for _,c in pairs(game:service(sources[i]):children()) do
	c.DescendantAdded:connect(function(desc)
		if desc.Name then
			desc.Name = FilterString(desc.Name)
		elseif desc.Value then
			desc.Value = FilterString(desc.Value)
		elseif desc.Text then
			desc.Text = FilterString(desc.Text)
		else
			warn(desc.Name .. " does not need to be filtered")
		end
	end)
end
end

It should filter everything that gets added to the workspace, lighting, replicatedstorage, etc.. But it doesn't seem to do anything. Please help!

EDIT: "ThingsToFilter" script in Workspace:

local thingstofilter = {
	"Value",
	"Name",
	"Text",
	"Parent"
}

return thingstofilter

2 comments

0

Can you explain what you are trying to do? What do you mean by filtering text?

0

"It should filter everything that gets added to the workspace, lighting, replicatedstorage, etc.. But it doesn't seem to do anything."