I have a textbox screen GUI, and whenever the player types something on it and presses enter, it fires the server to send that message to a surface GUI text label.
RS.TextBoard.OnServerEvent:Connect(function(player, text)
local filteredText = ""
local success, errorMessage = pcall(function()
filteredText = textService:FilterStringAsync(text, player.UserId)
end)
if not success then
warn('Error filtering text "', text, '": ', errorMessage)
filteredText = "Failed to filter message."
end
print(filteredText)
script.Parent.Text = filteredText
end)
Filtered text just returns the word “Instace”
I read another topic on this and I tried changing :FilterStringAsync() with :GetNonChatStringForBroadcastAsync() but that just printed a warning saying that GetNonChatStringForBroadcastAsync is not a valid member of textservice.
Read: FilterStringAsync. It returns a TextFilterResult which then you call one of the get methods from to get the string with an appropriate level of filtering. You don’t call it directly from TextService.
There’s a code sample at the bottom of the page. FilterStringAsync returns a TextFilterResult, then you call a method from that result.
local filterResult = TextService:FilterStringAsync(...)
local filteredText = filterResult:GetNonChatStringForBroadcastAsync()
Second thing is irrelevant plus Google exists for that. It’s somewhat crude wording so I changed it to “read” instead. It’s an acronym regarding your questions already being answerable if you just read the documentation for the functions you were using or did some debugging.
RS.TextBoard.OnServerEvent:Connect(function(player, text)
local filteredText = ""
local success, errorMessage = pcall(function()
filteredText = textService:FilterStringAsync(text, player.UserId)
end)
if not success then
warn('Error filtering text "', text, '": ', errorMessage)
script.Parent.Text = "Failed to filter message."
else
local filteredString = filteredText:GetNonChatStringForBroadcastAsync()
script.Parent.Text = filteredString
end
end)
I tested it but the text filter doesn’t seem to be doing it’s job.