Variable

A name for a value, made with local and changed with =.

Think of it as A name tag stuck on a value.

local coins = 0 makes a tag called coins and sticks it on 0. = moves the tag to a new value. A misspelt name is a different, empty tag, which reads as nil. Names are case-sensitive.

Where the picture breaks

Two tags can be stuck on the same table, so changing the table through one tag shows through the other, because there is only one table.

Variables hold values. Numbers, strings and booleans are copied on assignment, but tables and functions are reference values, so assigning a table copies the reference, not the contents.

See it with the rest of the analogy cast

Related terms