In my game (not public) there is a PlayersCard where players can add their own info such as Nicknames and other things which include text/string. And while reading the article about TextBox (since I am a bit new to using that object) I wondered how can I use the roblox filter to avoid inappropriate usage.
The filter seems complicated so basically I should do something like this:
local TextBox = script.Parent
–Let’s say our player is trying to be funny and writes things that will be censored (f-word and mean thing to say)
TextBox.FocusLost:Connect(function()
–So when the player has done typing
–(goes through the filter)
– so both things will be ####
print(TextBox.Text)
–The there’s other things fired (events)
end)
It’s a quick question but the article seemed confusing to me.
Thanks for reading.
Make a remote called FilterText in replicatedstorage.
Make a localscript into the text box.
Make a regular script in server script service.
-- LOCALSCRIPT FOR THE TEXTBOX
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
if script.Parent.Text ~= "" then
local filteredtext = game.ReplicatedStorage.FilterText:InvokeServer(script.Parent.Text)
if filteredtext then
print(filteredtext)
else return;
end
else return;
end
end)
-- SCRIPT FOR SERVERSCRIPTSERVICE
local textService = game:GetService("TextService")
game.ReplicatedStorage.FilterText.OnServerInvoke:Connect(function(player, text)
local filteredtext = nil;
local success, err = pcall(function()
filteredtext = textService:FilterStringAsync(text, player.UserId)
end)
if success then
return filteredtext
else
return false;
end
end)