Help adding in Roblox Filter to prevent possible moderation

I am wanting to implement roblox’s filter into a microphone script (where it creates a message instance from player speaking)
My concern is, if something is not done about this, it could result in the game being taken down.
Here is the issue, blurred due to swears.

What I have tried so far is implementing TextService:FilterStringAsync
However, it seems that will not be the case, and will not work…

Code is given below

local Online = script.Parent.On.Value;
function UpdateStatus()
	Online = script.Parent.On.Value;
end

local CurrentMessage;
local CollectionNum = 0
local CollectionThread = coroutine.create(function()
	while script.Parent do
		if CollectionNum > 0 then
			CollectionNum = CollectionNum - 1
		elseif CollectionNum == 0 and CurrentMessage then
			CurrentMessage:Remove()
			CurrentMessage = nil
		end
		wait(1)
	end
end)
coroutine.resume(CollectionThread)
function SetMessage(msg)
	if CurrentMessage then
		CurrentMessage.Text = msg
		CollectionNum = 4
		return
	end
	CurrentMessage = Instance.new("Message")
	CurrentMessage.Name = "MicAnnounce"
	CurrentMessage.Text = msg
	CurrentMessage.Parent = workspace
	CollectionNum = 4
end

function ExplodeStr(divider, text)
	if text == nil or divider == nil then return {} end
	if tostring(text) == "" then return {} end
	if tostring(divider) == "" then return {text} end
	local text = tostring(text)
	local divider =  tostring(divider)
	local position = 0
	local words = {}
	for start, stop in function() return string.find(text, divider, position, true) end do
		table.insert(words, string.sub(text, position, start - 1))
		position = stop + 1
	end
	table.insert(words, string.sub(text, position))
	return words
end

function FixMsg(str)
	local Parts = ExplodeStr('.', tostring(str))
	for Index, Part in pairs(Parts) do
		local New = Part:lower()
		print(New)
		local StrIndex = 0
		for i=1, #New do
			if New:byte(i) > string.byte('a')-1 and New:byte(i) < string.byte('z')+1 then
				StrIndex = i
				break
			end
		end
		if StrIndex == 0 then StrIndex = 1 end
		New = (function() return StrIndex ~= 1 and New:sub(1, StrIndex-1) or '' end)() .. New:sub(StrIndex,StrIndex):upper() .. New:sub(StrIndex+1)
		print(New)
		Parts[Index] = New
	end
	return table.concat(Parts, '.'):gsub(" i "," I ")
end

function IsInRange(plr)
	return plr:DistanceFromCharacter(script.Parent.Position) <= 15
end

local cons = {}
function ConnectPlayer(plr)
	if not plr then return end
	if plr and not plr:IsA("Player") then return end
	local PlrCon = plr.Chatted:connect(function(chat)
		if chat:find("/") or chat:find("\\") then return end
		if IsInRange(plr) then
			SetMessage(FixMsg(chat))
		end
	end)
	table.insert(cons, PlrCon)
end
function RegenConnections()
	for _, connection in pairs(cons) do
		pcall(function() connection:disconnect() end)
	end
	cons = {}
	for _, plr in pairs(game:GetService("Players"):GetChildren()) do
		ConnectPlayer(plr)
	end
end

for _, plr in pairs(game:GetService("Players"):GetChildren()) do
	ConnectPlayer(plr)
end
game:GetService("Players").ChildAdded:connect(ConnectPlayer)
2 Likes

Before I bother looking at the code I should tell you that filtering does not work in Roblox studio only on the actual game. test it there and if it still doesn’t work tell me

Yeah:
I did think about that…I just dont feel like its a good idea to test it in game…

Currently…unedited, I know it still does not filter it.

Your code is complicated I don’t want to dissect it, simplify it so that whatever the final part of code that prints the string runs it through this, Text filtering | Documentation - Roblox Creator Hub

Honestly text filtering seems unnecessarily complicated as I don’t see why you shouldn’t be able to just do like

Filteredstring = tts:FilterString(string)

keep in mind it was late lol, probably my brain just started shutting down and wasn’t sure.

I have solved this…I was just quite tired last night and forgot studio usually filters things.
Also made it less complicated so there is that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.