local var1 = math.random(a,z),(0,9) local var2 = math.random(_),(0,9) local var3 = math.random(a,z),(0,9)
print(var1..var2..var3)
i need var1 to choose a random number or letter var2 is an underscore or a number var3 is a letter or number
local var1 = math.random(a,z),(0,9) local var2 = math.random(_),(0,9) local var3 = math.random(a,z),(0,9)
print(var1..var2..var3)
i need var1 to choose a random number or letter var2 is an underscore or a number var3 is a letter or number
If you wanted something to be a letter or number you could have a math.random(0,35)
If the number is anywhere from 0-9 then set it equal to value (a number), else subtract 9 from the value and have an alphabet table like this...
local alphabet = { "a", "b", "c", "d", ... }
Where if you would get a random letter by doing alphabet[value] (a letter).
The built in function "string.char(...)" does this in a slightly nicer way. string.byte("a") gives the alphanumerical code of "a". So, string.char(math.random(string.byte("a"), string.byte("z"))) should be what you want
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
math.random only takes in 2 values so math.random(MinNumber,MaxNumber)
Please code block your code using the Lua button in the message editor.