Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a Random Name Generator?

Example of what I want it to do: z24j2ksahj2190!**@#jnkasjk!*n238

How do i make a script that names itself something like that but shorter?

2 answers

If you want to generate a random string, firstly create an array with all of the characters you want to include:

Characters = {"a", "b", "c", "d", "e", "f", "g" -- and so on... }

Then select a random number with the range of the length of your array:

RandomNumber = math.random(#Characters) -- The #Characters gets the length of the array.

Now index this random number to select a random item in the array and concatenate (join together) this into a string variable.

String = ""

for i=1, 10 do -- The number 10 is how long you want the string to be.
	String = String..Characters[RandomNumber]
end

print(String)

Please excuse any errors, as I made this up on the spot. I may have misinterpreted the question, but I hope this helps.

3 comments

0

ill try it out looks like it would work as expected though!

0

You could use "string.char(math.random(34, 122))" instead of a character table to make it shorter. Otherwise, good answer!

0

Please accept my answer if it helped!

i know im like 3 years late but for anyone looking for this i did this:

function randomstring()
	local length = math.random(10,20)
	local array = {}
	for i = 1,length do
		array[i] = string.char(math.random(32,126))
	end
	return table.concat(array)
end

if you would want to use it, write the function and then do (instance).Name For example,

function randomstring()
	local length = math.random(10,20)
	local array = {}
	for i = 1,length do
		array[i] = string.char(math.random(32,126))
	end
	return table.concat(array)
end

script.Name = randomstring()

and the script name would be something like "|_x^f6`I@'^v5I;<00VW"

This discussion is preserved as it was. New answers, comments, and votes are closed.