Feedback on my username generator script

Hello there i made a code that generates roblox usernames but im here to ask on how else can i improve the script?

local tablething = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
local Letters = {}
local Combined = ""
local UserId
for i=1,6 do
		table.insert(Letters,#Letters,tablething[math.random(1,#tablething)])
end
for i,v in pairs(Letters) do
	Combined = Combined..v
end
local success,errormessage = pcall(function()
	UserId = game.Players:GetUserIdFromNameAsync(Combined)
end)
if success then
	print(Combined.." Already exists. UserId: "..UserId)
else
	print(Combined.." Is not taken")
end
1 Like

You should have a list of words that can’t be generated to prevent certain words from being generated. Also, instead of writing the name into a table and writing the letters in that table to a string, what if you directly added it to the string?
Combined = Combined…tablething[math.random(1, #tablething)]

I’m not sure what you meant to achieve by adding #Letters in the middle, it works fine without it!

table.insert(Letters,tablething[math.random(1,#tablething)])

Overall it is a pretty decent script to find if a randomly generated username is available!

I added a few changes to your script to repeat if the username is unavailable! Not sure if it would help but it was fun to mess around with either way.

local A0 = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',}
local UserId
local Combined
local Letters = {}
local Characters = 3
local MaxTries = 100

local function r()
	local tries = 0
	local success
	repeat
		tries = tries + 1
		for i in pairs (Letters) do
			Letters[i] = nil
		end
	for i=1,Characters do
			local randomletter = A0[math.random(1,#A0)]
			table.insert(Letters,randomletter)
	end
	Combined = ""
	for i,v in pairs(Letters) do
		if #Letters == Characters then
			Combined = Combined..v
		else
			Combined = "Desiccate"
		end
	end
	print("["..tries.."] ".."Searching for "..Combined.." availability.")
		success = pcall(function()
			game:GetService("Players"):GetUserIdFromNameAsync(Combined)
		end)
		if success then else print(Combined.." is an available username!") end
		
	until tries == MaxTries or not success
	
	if success then
		print("Could not find available username.")
	end
end
r()