Sink
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
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:
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
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
<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:
That is a global variable (can be used anywhere), you can define them as a local one by using the keyword local
e.g:
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.
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.
Anyways, this is the end of my post, i hope you were able to understand the ‘magic’ behind this
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:
print(text)
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
<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
e.g:
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: