Random generated vehicle plates getting censored

I’m working on a script to generate random license plates for vehicles when you spawn a vehicle.

The pattern is AAAXAXX (A = letter, X = number)

I have done this script so far:

	local attempt = 0
	local TextService = game:GetService("TextService")
	local ok = false

	repeat
		local plate = GeneratePlate('mercosul') -- Returns a random string in the format AAAXAXX
		local filteredTextResult = nil

		local success, TextFilterResult = pcall(function()
			return TextService:FilterStringAsync(plate, game.Players.LocalPlayer.UserId)
		end)

		attempt = attempt+1
		if success then
			local FilteredText = TextFilterResult:GetNonChatStringForBroadcastAsync()
			ok = true
			print("[Attemp: "..attempt..'] '..plate..' passed the filter.')
			break
		else
			warn("[Attemp: "..attempt..'] '..plate..' was censored. Retrying...')
		end
		task.wait(.1)
	until ok == true

However, EVERY plate is getting censored. I left the script running for a while and the loop repeated over than 2,500 times and didn’t get an uncesored string.

Why is this happening and what can I do to avoid sending too many requests and get a quick response? (without the need to create my own database with plates that won’t be randomly generated and will just be taken from an array or something like that)

Or maybe my script is wrong?

Based on the code example in the documentation, I believe that if success is false, there was an issue with the service, and not that it was censored. If it was successful, it could still return a censored version of the text you provided.

image

1 Like

I’m pretty sure that if success is false, the result will be an error message you can print to see whats wrong. I think thats how pcalls work for service methods like that.

1 Like