Q:

math.random() only returns 1?

I was trying to generate a random number in between 1,100 but when i print the number it always returns 1
this is my current code:
local num = 100
local randomNum = math.random(1,num)
print(randomNum) --> 1

A:

Lua's math.random() "is an interface to the underling pseudo-random generator function provided by C". You need to seed the random number generator using math.randomseed() if you want different results on successive runs of your program. One common approach is to seed the pseudo-random number generator with the current time.
If you change your program to print 10 results of math.random(), you'll get a sequence of 10 random-looking numbers -- and that sequence will be the same every time you run your program.
See the rand() and srand() functions in C.
Note that C's rand() typically does not produce high quality pseudo-random numbers. They're likely to be good enough for a game, but not nearly good enough for cryptography.
(On my system, I get 85 every time I run your program. It's going to vary depending on the characteristics of the C runtime library.)

