Recently, I’ve been trying to implement text filtering into my game, but roblox is sniping down anything the player says, no matter how harmless. This makes playing the game literally impossible as talking through envelopes is one of the core concepts. I don’t know if I did something wrong with my code, or if this is just roblox being roblox, but this is never an issue in other games, so I’m a bit confused here.
Any help would be appreciated!
local Module = {}
local TextService = game:GetService("TextService")
local Events = game.ReplicatedStorage:WaitForChild("Events")
Module.Setup = function()
Events.RequestFilteredText.OnServerInvoke = function(player, inputText)
print(inputText)
if typeof(inputText) ~= "string" or inputText == "" then
return "[Invalid input]"
end
local success, filterResult = pcall(function()
return TextService:FilterStringAsync(inputText, player.UserId)
end)
if not success then
warn("Error generating TextFilterResult:", filterResult)
return "[Filter failed]"
end
local ok, filteredText = pcall(function()
local finalResult = filterResult:GetNonChatStringForUserAsync(player.UserId)
return finalResult
end)
if ok then
return filteredText
else
warn("Error retrieving filtered text:", filteredText)
return "[Filter error]"
end
end
end
return Module