Variable

In Lua, variables are values that allow scripts to store information in memory. There are eight basic types of variables in Lua, and the eight basic types are nil, number, string, boolean, table, function, userdata, and thread.

To assign a value to a variable, use the syntax "variable = 10".

nil
The nil variable is the default variable type, which all unassigned variables take the form of.

Number
The number variable is what the name suggests, a floating point number of any value, and can be of a negative or positive value.

String
The string variable is a string of letters, and can contain most characters you can type. To create a string, wrap text in double quotes ("") or single quotes ( '' ), or within brackets if you want a multi-line string.

Boolean
The boolean variable takes the form of either a true or false value, with true being on, and false being off. If a Boolean is not false then it must be true, and if it is not true then it must be false. The not operator can be used before a boolean value to invert it (so "not false" is equal to true and "not true" is equal to false).

Table
In Lua, the table variable is a general-purpose aggregate datatype that can store multiple variables (including additional tables). To create a table, use a matching pair of curly brackets ({}).

Function
In Lua, the function variable is a variable that when called, will run the same piece of code from multiple places, without having to duplicate the code in multiple places.

To create a function, use the function keyword (for example, newFunction = function print(newFunction) end).