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:
1 | 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:
1 | 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.
1 | String = "" |
2 |
3 | for i = 1 , 10 do -- The number 10 is how long you want the string to be. |
4 | String = String..Characters [ RandomNumber ] |
5 | end |
6 |
7 | 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:
1 | function randomstring() |
2 | local length = math.random( 10 , 20 ) |
3 | local array = { } |
4 | for i = 1 ,length do |
5 | array [ i ] = string.char(math.random( 32 , 126 )) |
6 | end |
7 | return table.concat(array) |
8 | end |
if you would want to use it, write the function and then do (instance).Name For example,
01 | function randomstring() |
02 | local length = math.random( 10 , 20 ) |
03 | local array = { } |
04 | for i = 1 ,length do |
05 | array [ i ] = string.char(math.random( 32 , 126 )) |
06 | end |
07 | return table.concat(array) |
08 | end |
09 |
10 | script.Name = randomstring() |
and the script name would be something like "|_x^f6`I@'^v5I;<00VW"