Skip to content

CustomRange

A CustomRange is almost identical to the Roblox NumberRange except it provides extra functionality. The Min and Max properties can be changed after the CustomRange is created.


Summary

Properties

Min
Max

Methods

InRange (x: number, inclusive: boolean) : boolean
Values () : number, number
Random (inclusive: boolean) : number
Lerp (alpha: number) : number
Unlerp (x: number) : number

Properties

Min

CustomRange.Min ( ) : ()


Max

CustomRange.Max ( ) : ()


Methods

InRange

If inclusive, checks if x >= Min and x <= Max. Otherwise, checks if x > Min and x < Max.

CustomRange:InRange ( x: number, inclusive: boolean ) : boolean

Parameters

x : number
inclusive : boolean
Whether the range should be inclusive or exclusive. Defaults to true (inclusive).

Returns

boolean

Values

Returns the minimum and maximum values of the range as a Tuple.

CustomRange:Values ( ) : number, number

Returns

number
number

Random

Returns a random number between Min and Max. If the range is exclusive, it will return a number between Min and Max that is not equal to either.

CustomRange:Random ( inclusive: boolean ) : number

Parameters

inclusive : boolean
Whether the range should be inclusive or exclusive. Defaults to true (inclusive).

Returns

number

Lerp

Returns a number between Min and Max based on the alpha value. If alpha is 0, it will return Min. If alpha is 1, it will return Max. If alpha is 0.5, it will return the midpoint between Min and Max.

CustomRange:Lerp ( alpha: number ) : number

Parameters

alpha : number

Returns

number

Unlerp

Returns a number between 0 and 1 based on where x falls between Min and Max. If x is equal to Min, it will return 0. If x is equal to Max, it will return 1. If x is halfway between Min and Max, it will return 0.5.

CustomRange:Unlerp ( x: number ) : number

Parameters

x : number

Returns

number