• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Tutorial Your (maybe) first Lua Program


New Coder
Requirements: a lua interpreter sitting tight with you

You may be new to lua, so keep in mind: Lua and Luau (Roblox Lua Scripting) may not have the same process.

You will learn how to show the text you want in the screen.

So, here we go.

We can do this by using the power of print()

Here's how you will do it:


You probably got the hang of this now, but put quotation's marks in your text "like this" or maybe 'like this, it's your choice really'.

We will end up with something like this:

print("Hello World")

Output: Hello World

Good job! You probably just wrote your first Hello World program In Lua!

But hold up, there's more

We can also do this with variables

We define one like this<name> = <value>

This may seem complicated at first, but let's break this up into parts:

<name> -The Variable Names ( *note: Lua is a case sensitive language, so hi and Hi are not the same variables*)

= -We are assigning a value


You see this, and may ask: "Where are we defining the variable type?" And the thing is: we don't. A variable can hold any data type, and Float's And Integer's values are defined as  Numbers in Lua. There are ways to see whenever the value is int or float, but you won't see this... For now :)

Here is a quick example:

x = 10

That is a global variable (can be used anywhere), you can define them as a local one by using the keyword local


local y = 20

But anyways, let's go back to our main objective: *Printing our variable*

To do this, we do the same thing as before expect we put our variable name and without quotation marks.

print(x) --output: 10

Boom! There we go! Wait... What are the double dashes ('--')?

These are comment's in Lua, they are ignored by the program and can help you and other people understand your code.

--haha Comments, go brrr

Anyways, this is the end of my post, i hope you were able to understand the ‘magic’ behind this
Last edited:
Top Bottom