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)