START HERE·LUA FROM ZERO·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this whole lesson - every step, code block, and the exact console errors - plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.
Start Here · Lua from zero

Your first line of Lua

Every coder you have ever heard of started the same way: one line that prints a message, and the small thrill of seeing the computer say it back. That is the whole win of this lesson. You will type a line of real Lua code, press a button, and watch the output appear, all without installing anything. No server, no setup, no files to manage. Just you and your first line.

You'll learn
What the print function does, what a string is, and how to read the output it produces
Time
~10 minutes
Difficulty
Absolute beginner. No coding experience needed.
You need
Nothing to install. This lesson runs real Lua right here in your browser.

Watch

RED: writing your first Lua, starting from nothing.
BEFORE YOU START

What "print" is

The first tool every programmer learns is a way to make the computer show you something. In Lua, that tool is called print.

Here is the one sentence to hold onto: print is a built-in command that writes text to the output so you can read it. That is its entire job. You give it some text, it shows that text. Nothing more.

A few of those words need defining, because we will use them constantly from here on.

Vocabulary

print
A built-in function in Lua that takes text and writes it to the output. It is built in, meaning Lua gives it to you for free; you never have to create it.
function
A named action you can run. You run a function by writing its name. Think of it as a verb the computer already knows how to do, like print or save.
string
A run of text the computer treats as one value, such as the words Hello, Los Santos. The word string just means a string of characters, like beads on a thread.
console
The plain-text screen where a program writes its output and you can type commands back. In this lesson, the console is the output box of the sandbox below. On a real server it would be the server console.

When we say print is a function, we mean it is an action with a name. The action is write this text out where I can see it. You trigger that action by writing the name print and handing it the text you want shown. The computer does the rest.

Why it matters

This sounds almost too simple to bother with. It is not. print is how you see what your code is doing, and seeing what your code is doing is most of programming.

Code runs silently. The computer does not narrate its work. If something goes wrong, or if you just want to confirm a value is what you expect, you reach for print. You drop it into your code, run the program, and read the output. That is the move. Every debugging session a professional developer runs, on any project in the world, starts with some version of "let me print this and see what it actually is."

So you are not learning a toy. You are learning the single most-used tool for understanding your own code, on day one.

Run your first line

Enough talk. Here is your first line of real Lua. Press the Run button and watch the output box.

sandbox.luaLUA 5.4
OUTPUT
Press RUN to execute.

The instant you press Run, Lua reads your line, sees print, takes the text you handed it, and writes that text to the output. You should see this:

That is it. You just ran code. The text you put inside print came back out in the console, exactly as promised. Sit with that for a second, because the loop you just did, write a line, run it, read the output, is the loop you will repeat thousands of times from here on.

How it works

You ran the line and it worked. Now take it apart, one piece at a time, so that next time you are deciding what to write instead of copying. There are only three things on that line, and each one has a clear job.

The string

Look at the text inside the parentheses:

lua
"Hello, Los Santos"

That is a string. The two quote marks are not part of the message. They are fences. They mark exactly where your text starts and where it ends, so Lua knows that Hello, Los Santos is the value and not a piece of code to run. When Lua prints it, the fences are dropped and only the text between them comes out. That is why the output reads Hello, Los Santos and not "Hello, Los Santos" with the quotes.

Lua accepts both single and double quotes, and they mean the same thing. These two lines produce identical output:

lua
print("Hello, Los Santos")
print('Hello, Los Santos')

Pick one style and stay consistent. The only rule is that the quote you open with must match the quote you close with.

The function call

lua
print("Hello, Los Santos")

This whole line is a function call, which is just the act of running a function. A function call has three parts you can see plainly here:

  • The name of the function: print. This tells Lua which action to run.
  • A pair of parentheses: ( ). These hold whatever you are handing to the function.
  • The value inside the parentheses: your string. The value you hand to a function is called its argument. Here, print has one argument, the string "Hello, Los Santos".

Read in plain words, the line says: run the print action, and the thing to print is this string. That mental shape, name then parentheses then the value inside, is how every function call in Lua looks. You will recognise it everywhere now.

Comments

One more thing you will see in real code: comments. A comment is a note for humans that Lua ignores completely. You write one with two dashes, --, and everything after them on that line is skipped when the code runs.

lua
-- This line is a note. Lua does not run it.
print("Hello, Los Santos")  -- you can also put a comment at the end of a line

Comments are for explaining why you did something, leaving reminders, or temporarily switching off a line without deleting it. They never affect the output.

Common beginner mistakes

Two errors trip up almost everyone on their very first line. Both are easy to fix once you can recognise them. Try breaking your code on purpose in the sandbox above, then fixing it, so the error messages stop being scary.

SymptomFix
unexpected symbol near '...'A quote is missing or the two quotes do not match. Every string needs a matching pair of quotes around it, like "this" or 'this'. Check that you opened and closed with the same quote character.
Nothing printsMake sure your text is inside the parentheses of print( ), and make sure you actually pressed Run. An empty output box usually means the line did not run or there was no print.
Why are the quotes around Hello, Los Santos not shown in the output?

Because the quotes are fences, not text. They exist only to mark where the string starts and ends so Lua knows that Hello, Los Santos is your message and not code. Once Lua has the string, it drops the fences and prints only the text between them. That is why the output is Hello, Los Santos with no quotes.

Try it yourself

Time to make it yours.

Bonus: print can take more than one value

You can hand print several values at once by separating them with commas. Lua prints them on the same line with a gap between each. Try this in the sandbox:

lua
print("Server:", "Los Santos RP", "Status:", "online")

This is handy later when you want to print a label next to a value, like print("player count:", count), so the output reads clearly instead of being a lone mystery number.

What you can do now

  • Explain that print is a built-in function whose job is to write text to the output.
  • Write a string and explain why the quotes are fences, not part of the message.
  • Run a function by writing its name, parentheses, and the value to hand it inside them.
  • Use the write, run, read loop to see what your code is actually doing.
  • Read the two most common first-line errors and fix them.

You wrote and ran real Lua with zero setup. That is the hardest step, and it is behind you now. Next you will store values so your code can remember and change them, instead of typing the same text by hand every time. That lesson is "Variables: numbers and text," and it is where your code starts to feel alive.