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

cant use math.random how do i make it do this?

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

2 comments

0

math.random only takes in 2 values so math.random(MinNumber,MaxNumber)

0

Please code block your code using the Lua button in the message editor.

1 answer

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).

1 comment

0

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.