Data Types and Variables

The types of data in RapidScript and how to use them.

Data Types

RapidScript programs, similar to many other computer programs, store data as binary bits. RapidScript programs will then interpret those bits into the following forms:

  • bool: Can hold one of two values, true or false.

  • Signed Integers: Represents integer values within a certain range, depending on the number of bits they have. The following signed integer types can hold the values within the given ranges (inclusive).

    • int16: -32,768 to 32,767

    • int32: -2,147,483,648 to 2,147,483,647

    • int64: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

  • Unsigned Integers: Represents non-negative integer values up to a maximum value, depending on the number of bits they have. The following unsigned integer types can hold the values within the given ranges (inclusive).

    • uint16: 0 to 65535

    • uint32: 0 to 4,294,967,295

    • uint64: 0 to 18,446,744,073,709,551,615

  • double: Represents numbers with fractional values (numbers with decimal points).

  • string: Represents sequences of characters (often words or sentences).


To utilize the stored data, RapidScript programs assign a name to each data field. The resulting pair is known as a variable. By using the declared name of the variable, users may read or write to the stored value.


Before using any variable, its data type and name must be declared. In RapidScript, a basic variable declaration follows the format:

<data type> <name>;

For example, if we wanted a double value to represent our current position, we would write the following line:

double position;

Initialization and Assignment

After declaring a variable, we must assign it a meaningful value. Before reading the variable's value, we must assign it an initial value. If we use it before initializing, it may hold some random value and lead to undesired program behavior.

An assignment is done via the = operator, and follows the format:

<name> = <value>;

Initialization may occur in the same statement as the declaration:

double position = 1234;

Or later in the program as a basic assignment statement:

position = 5678;

As a note, everything on the right side of the = operator will be evaluated before assigning the value to the variable.

Reading the Value

Reading the value stored in a variable is as simple as substituting its name wherever it needs to be used. During execution, the RapidScript program will substitute the current value of the variable wherever the variable name is present.

For example:

double position = 0;
int32 initial = 1234;
int32 increment = 10;
position = initial + increment;

Will print out the value of initial + increment, which is 1234 + 10 = 1244.

Raw values in code such as 1234 in the snippet above are referred to as "literals". Literals can be of any data type.

Last updated