Math.random (SOLVED)

So I know its not possible for a computer to generate a new pair of numbers every time it runs since a computer is made to follow commands

But is there some sort of data I can acess within the script that is always different?
(Like the time when the program started running)
So I can go like
Time = 1325
A = Time 2 - 400
A = Time / A
A = A
Time
If A < math.random(500,1900)
. Do this
Else
. Do that
End

Don’t know if that’s what you mean, but maybe it would be helpful to know that you can set a seed basing on OS time:

math.randomseed(os.time)

There are also random number generators on the asset page

2 Likes

As @Pawel says before you use math.random you need to set a seed. You will also need to pop a few of the random numbers before hand. So call math.random 3-5 times just after you do math.randomseed. For some reason I have had problems with math.random when giving it a seed based on time. For some players the seed still doesn’t seem to change (might be because their device is faulty who knows). Because of this I tend to use something else like @selimanac’s defold-random.

4 Likes

Thanks i didnt know theres a thing calls os.time

1 Like

Im going to use this asset from now on its gold

1 Like