Math.random() or Random:NextNumber/Integer()?

Hello,

I read somewhere that Random:NextNumber/Integer() is more efficient and less biased than math.random(). I wanted to see your opinion on this as I am currently making a game which requires loads of RNG so that I know which is best to use.

1 Like

Both use the same algorithm, neither is more efficient or biased to use. Random just provides you with an extended range of features to use, a nicer API, various internal differences (ex. every new Random object gets a randomised seed from a source of entropy unlike math.randomseed which globally changes the random seed) and a seed that’s local to the object, among other items.

Release thread from its developer:

Other comments by its developer (ordered by newest relevant post first).

https://devforum.roblox.com/t/why-is-the-first-number-always-1/52224/5?u=colbert2677

Use either one.

P.S. Random is an object, not a library. You’d need to do Random.new():Next[Integer/Number].

8 Likes

Could you explain what a ‘seed’ is please? I am quite new to using the ‘Random’ Features.

Thank you for answering btw :slight_smile:

A seed is a number used to initialize a pseudorandom number generator.

3 Likes