How reliable is my filtering function?

I am trying to create a town naming script, like in Animal Crossing. This script is unfinished, and what I want to know is, is it reliable?

This script runs on the client, after the button has been clicked.

local replicatedStorage = game:GetService("ReplicatedStorage")
local filterFunction = replicatedStorage.FilterTextBox
local player = game:GetService("Players").LocalPlayer
local box = script.Parent.Parent.TownName

	local filteredText = filterFunction:InvokeServer(box.Text)
	box.Text = filteredText
	script.Parent.Parent.Parent.PlaceFilter.Visible = true
	script.Parent.Parent.Parent.PlaceFilter.TextLabel.Text = "Your towns name is going to be <b>".. filteredText.. "</b>. Are you sure? You cannot change this later. "

This script runs on the server, and filters the text, then returns the filtered text

local rep = game:GetService("ReplicatedStorage")
local txtSer = game:GetService("TextService")
local filterFunction = rep.FilterTextBox
local filteredText

filterFunction.OnServerInvoke = function(plr, unfilteredText)
	filteredText = txtSer:FilterStringAsync(unfilteredText, plr.UserId)
	return filteredText:GetNonChatStringForBroadcastAsync()


If this is the most reliable this script it can be, great! Let me know otherwise on what I should change to make it reliable. Thank you, WE

1 Like

Your filtering script is as reliable as built-in filtering service is. Roblox employees are making effort to even further improve it as much as they can. Unfortunately, at the moment, it’s almost impossible to write a perfect filter, because there are countless ways to write something inappropriate and/or insulting. Someone can use uncommon Unicode characters to shape inappropriate letters or emojys, also use emojys themselves, other person might figure out that inserting Unicode characters instead of spaces between letters of bad word is a new loophole that can help bypass the filter. If the filter was so strict in attempts to cover all such potential cases (which is really hard to do), it would seriously restrict normal communication, and result in a lot of “false positives”.

So again, your script is as reliable as Roblox’s filter is. You’ve taken appropriate security measures, and don’t need to worry.

As far as I understand you script right now, you’re accepting the text written in the box by player, sending it to server for filtering and displaying the return. Safe and secure. Another important part is actual renaming. When player confirms the name, send a signal to the server. Naming relies solely on server, which means it applies the stored string. Any naming done by client won’t replicate. Another fact to mention is that clients control their graphical interface, so any changes they make for themselves is pretty much out of control by developers.

Here is the code with short debounce and name storing:

local RepStorage = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")

local DEBOUNCE_TIME = 0.5

local filterFunction = RepStorage.FilterTextBox
local filteredText

local names = {}
local queue = {}

local function coolDown(player)
	queue[player.UserId] = true
	queue[player.UserId] = nil

filterFunction.OnServerInvoke = function(player, unfilteredText)
	if (queue[player.UserId]) then
		-- decide what to do and what to return here
		return ""

	filteredText = TextService:FilterStringAsync(unfilteredText, player.UserId)
	filteredText = filteredText:GetNonChatStringForBroadcastAsync()
	names[player.UserId] = filteredText
	return filteredText

To sum it up, generally looks good, so keep up the good work!