Random

Provides access to generating pseudorandom numbers using various Random Engines.

Random Engines refer to Pseudo Random Number Generators, of which 3 are built in.

Constructors

Random.new(seed: number?, randomEngine: Enum.RandomEngine?)

Methods

Random:NextNumber(min: number, max: number): number
Random:NextInteger(min: number, max: number): number
Random:Shuffle(table: {})

Constructors

Random.new()

Creates a new Random class with an optional seed and Random Engine

Random.new(seed: number?, randomEngine: Enum.RandomEngine?)
Parameters Description
seed : number? Seed to initialize the Random Engine with. Defaults to 12345
randomEngine : Enum.RandomEngine? The type of Random Engine to use. Defaults to Enum.RandomEngine.WELL512

Methods

Random:NextNumber

Returns a random real number between the minimum and maximum, updating the internal state of the Random Engine.

Random:NextNumber(min: number, max: number): number

Random:NextInteger

Returns a random integer between the minimum and maximum, updating the internal state of the Random Engine.

Random:NextInteger(min: number, max: number): number

Random:Shuffle

Shuffles the table in-place.

The shuffle is a Fisher-Yates shuffle, so each index is equally likely, and the NextInteger calls are always the same for a given size of the table.

Random:Shuffle(table: {})