How do I fix this?
local textService = game:GetService("TextService")
game.ReplicatedStorage.FilterText.OnServerEvent:connect(function(player, text)
pcall(function() print(textService:FilterStringAsync(text, player.UserId)) end)
end)
FilterStringAsync
returns not a string
, but a TextFilterResult
.
TextFilterResults
is a better way to get filtered strings. A TextFilterResult
has 3 main methods.
GetChatForUserAsync
is a method that filters a string that is intended to display for a certain user.
This is best used for private chats.
GetNonChatStringForBroadcastAsync
is a method that filters a string that is shown to everyone in a non-chat context.
This is best used for public signs (such as naming a restaurant, or giving yourself another nickname)
GetNonChatStringForUserAsync
is a method that filters a string that is shown to a certain user in a non-chat context.
This is best used for private signs (signs, like mentioned above, that is only shown to that one user)