Your First Lua Script

Let’s write our first Lua program to get comfortable with the syntax.

Hello, World!

print("Hello, World!")
  • print() is the built-in function used to display output in the console.

How to Run:

  1. Create a file named hello.lua
  2. Add the code above to it
  3. Open your terminal and run: lua hello.lua

That’s it! You’ve just written your first Lua script.

Try This:

name = "Klaus"
print("Hello, " .. name)

This introduces string concatenation using the .. operator in Lua.

← PrevNext →