Skip to main content
Random Number Block Screenshot

Overview

The Random Number Block, also known as RNG, generates a random number within a specified range. This block is useful for creating randomized behavior in your flow. The block can be configured to generate either integers or floating-point numbers. The range of the random number can be specified with a minimum and maximum value. The maximum value can be set to be either inclusive or exclusive.

Inputs

TitleData TypeDescriptionDefault ValueNotes
MinnumberThe minimum value of the random number. This input is only available if Use Min Input is enabled in the editor settings.(optional)The input will be coerced into a number if it is not a number.
MaxnumberThe maximum value of the random number. This input is only available if Use Max Input is enabled in the editor settings.(optional)The input will be coerced into a number if it is not a number.

Example 1: Generate a random integer

  1. Create a Random Number Block.
  2. Set the Min to 1 and the Max to 10.
  3. Enable the Integers setting.
  4. Run the flow. The output of the Random Number Block should be a random integer between 1 and 10.
Random Number Block Example 1

Example 2: Generate a random floating-point number

  1. Create a Random Number Block.
  2. Set the Min to 0 and the Max to 1.
  3. Disable the Integers setting.
  4. Run the flow. The output of the Random Number Block should be a random floating-point number between 0 and 1.
Random Number Block Example 2

Error Handling

The Random Number Block will error if the Min is greater than the Max. If the Min and Max are equal, the block will always output the Min value.

FAQ

Q: Can I use the Random Number Block to generate a random boolean value? A: Yes, you can use the Random Number Block to generate a random boolean value by setting the Min to 0, the Max to 1, and enabling the Integers setting. The block will then output either 0 or 1, which can be interpreted as false and true by a Bool Block. Q: Can I use the Random Number Block to generate a random string? A: No, the Random Number Block can only generate random numbers. If you want to generate a random string, you can use a Code Block with a custom JavaScript function.

See Also