Hi. When developing a filter script for my game, I came across an issue which caused the FilterString Async function to not filter text.
local TextService = game:GetService("TextService")
game.ReplicatedStorage.Events.Functions.Filter.OnServerInvoke = function(Player, String)
local result
local valid, err = pcall(function()
result = TextService:FilterStringAsync(String, Player.UserId, Enum.TextFilterContext.PublicChat):GetNonChatStringForBroadcastAsync()
end)
if valid then
return result
else
return false
end
end
Client script used to invoke filter server script
local filteredText = filterEvent:InvokeServer(NameTextBox.Text) -- (nametextbox = a*s)
print(filteredText) ---> a*s (doesnt filter)