Question About math.randomseed()

Hello, currently i’m creating a game project that use a random number generating using math.random(). I know that if i don’t want same number generated for the result, i must use math.randomseed(os.time()). So my question is are math.randomseed() is affect globally (in whole script/game) or only in a script that called it ?

Why don’t you test and see with two scripts generating random numbers? :sunglasses:

8 Likes

@Pkeod well i has test it and in my case it makes no difference either in one script or all script i have, so which way is better ? call it in one script or call it in every script that will call math.random() ? and if i put math.randomseed() inside update function, is it will affect to memory usage of the game ?

1 Like

Generally you would set it once in your main script in your main collection. For better RNG use MT https://github.com/subsoap/defrng/blob/master/defrng/mt.lua

2 Likes

Ok then, thank you for the answer and suggestion. It helped me so much

2 Likes