New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
1

# Random.new or math.random, which is superior?

## Which is better for constructing random object from a seed?

Lately, I have seen a brief discussion on the discord server about which is the best random number generator available on roblox. One person advised someone to use math.randomseed(tick()) and then do math.random(). However, another user said that Random.new() should be used instead of math.randomseed(). So, after I did a quick search on the wiki, I couldn't really discern the difference between math.randomseed and Random.new().

## Any differences between :NextInteger(min,max) and math.Random(min,max)?

So after researching Random.new, Random:NextInteger, and Random:NextNumber for a bit I am still confused about why, if both methods provide psuedo-random numbers, why have two ways to perform the same task. For example, the following two bits of code should generate psuedo-random integers between 0 and 200

local random = Random.new(tick())
while true do
print(random:NextInteger(0,200))
wait(2)
end


and

math.randomseed(tick())
while true do
print(math.random(0,200))
wait(2)
end


These two pieces of code should, essentially do the same thing, that being generating a psuedo-random number between 0 and 200. But that still raises the question of why, why have two different ways to accomplish the same thing?

So, if anyone has any idea of what the rationale behind having two ways of essentially doing the same thing, and if there is a different, which of the two methods is better, or "Random-er" than the other, that would be appreciated.

0
math.random follows the same algorithm as Random.new now, but Random has its own benefits nonetheless. User#19524 106 — 11mo
1
Biggest benefit of Random as far as I'm concerned - Random datatype includes the seed in its creation. If we set math.randomseed(tick()) - then throughout the whole script this will be the seed for math.random; however, with Random - we can do a = Random.new(seed1) AND b = Random.new(seed2) -- if we needed two separate pseudorandom number gens for whatever reason. SummerEquinox 638 — 11mo