Chapter 1: Variables, values and types 1.1: Variables 1.2: Values 1.3: Integers 1.4: Booleans 1.5: Strings Chapter 2: Properties and Instances Chapter 3: Conditionals and If Statements Chapter 4: Functions and Blocks Chapter 5: Event Listeners
Printing Syntax

Before we begin our discussion on how to utilize LUAU, the programming language in Roblox, we will make sure that you are familiar with printing. Printing is just displaying what you want displayed as text in the output box.

To print, you can simply write,
print(WHAT_YOU_WANT_TO_PRINT)
where WHAT_YOU_WANT_TO_PRINT is exactly what it spells. This will display WHAT_YOU_WANT_TO_PRINT in the output box given that WHAT_YOU_WANT_TO_PRINT is a correct type.

Not everything you put inside the print will work. Later in this chapter, you will discover what will work and how to use printing for debugging. For example, only adding print(hello) will not work and will give you an error.

1.1: Variables

LUAU, the programming language used in Roblox, has variables which are stored pieces of memory.

You can think of a variable as a name given to a value you want to store. If you wanted to store the number 10 and you wanted to name the variable ten, you would simply write
local ten = 10
The "local" keyword indicates that the variable is a local variable which allows for extremely fast access and will be explained in later chapters.

Variables in LUAU do not have types, rather values have types. A type can simply be explained as what kind of memory you want to store. There are many different types in LUAU which will be explored in the next few sections.

1.2: Values

LUAU consists of many different Values, including Integers, Strings, and Booleans.

Since different values are needed to store different types of data, the type of value used should be based on what type of data you are trying to store.

The next few sections will discuss the different types of basic values that exist in LUAU.

1.3: Integers

Integers are used to describe data in the form of numbers. Integers are especially useful because they can be used with many mathematical methods in order to manipulate them.

Integers can easily be stored in a variable by writing
local ten = 10
By writing the number "10" we indicate that the variable "ten" holds the number 10.

There are many mathematical methods we can use with integers including, "+", "-", "/", "*"

Therefore we can easily manipulate a variable containing an integer value.

local num = 10
num = num + 10 -- Here we change the variable "num" to store the previous variable of "num" which was 10 and added 10 to it
num = num - 10 -- Here we change the variable "num" to store the previous variable of "num" which was 20 and subtracted 10 to it
num = num/10 -- Here we change the variable "num" to store the quotient of the previous value of "num" and 10
num = num * 10 -- Here we change the variable "num" to store the product of the previous value of "num" and 10

Notice how we no longer use the keyword "local" after initializing the variable "num". This is because we only need to indicate the variable is a local variable in the beginning.

1.4: Booleans

Boolean values are denoted as either being true or false.

These values are particularly powerful when used in conditional statements which we will go over in later chapters.

Boolean values can be written as:
local Value = true
where "Value" is the given name of the Variable and "true" indicates a true boolean value.

Additionally, the keyword "not" is often used with booleans to indicate the opposite of a value. For example, if our variable "Value" is initially set to true as above and we write
Value = not Value
the variable "Value" would be given the opposite boolean value of "false".

1.5: Strings

String values are denoted by including quotation marks around a group of characters. Strings are essentially a list of characters and are often used to store words.

For example, if you wanted to store a name you would use a string value. Let's say we wanted to store the name "David". We would write:
local name = "David"
The quotation marks indicate that we are storing a string. With strings, we can store any sequence of characters.

Printing Variables and Values

In the first section of this chapter, you learned that what you put inside a print matters and not everything will print. You can either print variables or values. For variables you would just write print(variable_name), where variable_name is the name of the variable.

When it comes to printing values, all values can be printed without special wrapping, except for strings. Strings require quotations to be placed around the word.

local num = 10
print(num) -- Here we print the variable "num" which stores the value 10. 10 will be displayed in the output box
print(10) -- Here we print the number value 10, which will be displayed.
print(true) -- Here we print the boolean value true. This will display true in the output box.
print("Hello World!") -- Here we print the string value "Hello World!". This will display Hello World! in the output box.
Chapter 2: Properties and Instances