So I have a nickname filter which I am using:
function game.ReplicatedStorage.Remotes.CheckString.OnServerInvoke(player, text)
local textresualt
local FilteredString = TextService:FilterStringAsync(text,player.UserId):GetNonChatStringForBroadcastAsync()
print(FilteredString)
end
It works, but it doesn’t tell you if the string was filtered or not. I want it to return a boolean value that shows if it was filtered or not, so I can tell the player that the name should be changed because it will be hashtags otherwise.
It can be filtered yet still be the same message. If I say Hello, I doubt very much it’d call it inappropriate and censor it… So the filtered version and the original message can potentially be the same message.
I checked, for example, if I do something like “oder” then the message will be “####” which is not the same. But if I did “hi” it would return “hi” which is the same.
Exactly… If it fails that means that a potentially inappropriate message will be unfiltered. And with this method, you won’t be able to tell if it fails or not… The are hooked to Web Calls so they fail quite often… This can lead to your game getting moderated…
Yes but you need to handle the error and not continue with the original string. Either return that the request failed or retry a certain amount of times.
This is an example from the page of something that would help you.
local TextService = game:GetService("TextService")
local filteredText = ""
local success, errorMessage = pcall(function()
filteredTextResult = TextService:FilterStringAsync(text, fromPlayerId)
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
-- Put code here to handle filter failure
end