So I wrote a filter function but it doesn’t seem to return a filtered string. “Discord” should be filtered.
local filterResults = {}
local function broadcastPetName(userId)
local filterResult = filterResults[userId]
if filterResult then
local filteredString = filterResult:GetNonChatStringForUserAsync(userId)
filteredString = filteredString or ""
return filteredString
end
end
game.Players.PlayerAdded:Connect(function(player)
local fromUserId = player.UserId
local success, result = pcall(function()
return TextService:FilterStringAsync("discord", fromUserId)
end)
if success then
filterResults[fromUserId] = result
local result = broadcastPetName(fromUserId)
print(result)
else
print("Could not filter pet name")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local userId = player.UserId
filterResults[userId] = nil
end)