random number string lua code example
Example 1: how to get a random number in lua
local randomNumber1 = math.random(1, 10) --Returns a number between 1 and 10.
local randomNumber2 = math.random(10) --Also returns a number between 1 and 10.
print(randomNumber1, randomNumber2) --OUTPUT EXAMPLE: "6, 8"
Example 2: random string generator lua
function RandomVariable(length)
local res = ""
for i = 1, length do
res = res .. string.char(math.random(97, 122))
end
return res
end