When to use NumberRange?

I have no idea what NumberRange is used for. Any help is helpful thanks!

1 Like

NumberRange is used for situations where you need a max and min variable. Instead of making separate variables for max and min, you can just use NumberRange.

You can look at the API here: NumberRange | Roblox Creator Documentation


Here are some examples using NumberRange:

local range = NumberRange.new(15,30)
print(range)

You are printing out a min and a max value together, so the output would be

15 30 

To get just the min value, do:

local range = NumberRange.new(15,30)
print(range.Min)

Which should return the min value, 15:

15

You can do the same with the max:

local range = NumberRange.new(15,30)
print(range.Min)

Output:

30

I have never personally used NumberRange before either, so if anyone has any additional information or corrections, please reply!

2 Likes

Never mind I figured it out thanks

What are you putting in the NumberRange value that results in that error? The first value always has to be less than or equal to the second value.

1 Like

The first value was greater than the second value

1 Like