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?
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.
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"