Learnr

Learn Lua

A tiny, fast scripting language that lives inside games and apps.

or browse all courses.

Free to start. Built from a single prompt. No credit card.

Lua is a small, fast scripting language created at PUC-Rio in Brazil and designed to be embedded inside larger programs. Its whole interpreter is compact, so game engines and apps use it for scripting: Roblox runs a dialect called Luau, LÖVE builds 2D games with it, and Neovim and many World of Warcraft addons are configured with it. The language has one data structure, the table, which acts as array, dictionary and object. Arrays start at index 1 and variables are global unless marked local. Learnr builds a personalized Lua course from one prompt, tuned to the game or tool you care about.

How to learn Lua, step by step

  1. Run Lua and learn the core syntax. Install Lua or use an online interpreter and run print statements. Notice the quirks early: blocks end with end, not-equal is ~=, strings join with .., and comments start with two hyphens.
  2. Always declare variables with local. Variables are global by default in Lua, which causes hard-to-find bugs in bigger scripts. Make local a reflex, and learn that only nil and false count as false in conditions.
  3. Get fluent with tables. Build an inventory list, a dictionary of player stats and a nested config table. Loop with ipairs for array parts and pairs for keys, and remember the first array index is 1, not 0.
  4. Learn functions, closures and modules. Return multiple values, pass functions as arguments and write a counter with a closure. Split code into a module that returns a table, then load it with require.
  5. Build objects with metatables. Use setmetatable and the __index field to give tables shared methods, and call them with the colon syntax. This is how Lua code fakes classes, and how most game frameworks are structured.
  6. Script something real. Make a Pong clone in LÖVE, a game in Roblox Studio using Luau, or your own Neovim config. Short Learnr lessons with streaks keep the syntax fresh between building sessions.

What you'll learn

  • Write Lua with local variables, conditionals and loops
  • Use tables as arrays, dictionaries and objects
  • Write functions, closures and variadic functions
  • Build simple classes with metatables and __index
  • Script a small game in LÖVE or a similar engine

What's inside your Lua course

A sample path Learnr builds for Lua. Your real course adapts to your goal and level.

  • 1. Running Lua and basic syntax
  • 2. Variables, types, strings and control flow
  • 3. Tables as arrays and dictionaries
  • 4. Functions, closures and modules
  • 5. Metatables, objects and coroutines
  • 6. Embedding: games, Roblox and Neovim

How long does it take to learn Lua?

The core language is small, so many beginners can write useful scripts in 2 to 4 weeks at 4 to 5 hours a week. Making a finished game takes longer, mostly to learn the engine's API rather than Lua itself.

What you need before you start

Nothing beyond basic computer skills. If you are aiming at Roblox or a game engine, install that tool early so you can practice inside it.

Common mistakes to avoid

  • Forgetting local and accidentally sharing a global variable across scripts. Declare every variable local unless you really mean a global.
  • Expecting arrays to start at 0 and getting off-by-one errors. Lua tables start at 1, and the # length operator assumes no gaps.
  • Copying Roblox tutorials without knowing which parts are Luau or Roblox APIs and which are plain Lua. Learn the base language separately.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn Lua, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full Lua course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

Lua questions, answered

Is Lua the same as Roblox scripting?

Roblox uses Luau, a language derived from Lua 5.1 that adds gradual typing and performance features. Plain Lua skills transfer directly, but you also need Roblox's own API for parts, players and events.

Is Lua good as a first programming language?

Yes. It has a small, consistent syntax and gives quick results in games, which keeps beginners motivated. The concepts carry over to Python and JavaScript later.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn Lua?

Start your free, personalized Lua course in seconds. .