So I\'m trying to create a little something and I have looked all over the place looking for ways of generating a random number. However no matter where I test my code, it r
You need to run math.randomseed()
once before using math.random()
, like this:
math.randomseed(os.time())
One possible problem is that the first number may not be so "randomized" in some platforms. So a better solution is to pop some random number before using them for real:
math.randomseed(os.time())
math.random(); math.random(); math.random()
Reference: Lua Math Library