I’m doing filter("Player Name")
(since thats the info I’m passing now), and this is the function, itll always fail.
local filter = function(str)
local FilterCompleted, FilterError = pcall(function()
return textService:FilterStringAsync(str, 89366187);
end)
if isFiltering == false then
return str;
end
if FilterCompleted and not FilterError then
str = FilterCompleted;
else
return "Request dropped!"
end
return str;
end
When you return in a pcall the second variable (in your case FilterError) of the pcall will be what you returned.
-- 'FilterError' contains what was returned in the pcall not 'FilterCompleted'
local FilterCompleted, FilterError = pcall(function()
return textService:FilterStringAsync(str, 89366187);
end)
Additionally, FilterStringAsync alone doesn’t give you the filtered string you need to further it with TextFilterResult method you can find the three methods here: TextFilterResult
For my example below I’ll use the :GetNonChatStringForUserAsync() method:
-- filterStringResult is what 'textService:FilterStringAsync(str, 89366187)' gave
filterStringResult:GetNonChatStringForUserAsync(userIdSendingTo)