The Basics of Luau and what you need to know

Hi! So being in a couple Roblox help groups its pretty clear that starting out its very hard to understand, even some basic stuff which should be self explanatory. There are most likely a TON more tutorials on here but i’m making my own in words that a starter scripter can understand.

Before we get started i should mention both that things are most likely missing from this guide, and feel free to comment explaining what i missed and it will be added, and that also programming is not for everyone, you need to have the want to learn, and not give up

Start small and work your way up, always challange yourself, but never too much.

What is Luau?

Luau (lowercase u) is a modified version of lua specifically made for Roblox to suit their standards, it is a high level object oriented coding language.
I found a good example of the language tiers on javatpoint.com

The low-level language is a programming language that provides no abstraction from the hardware, 
and it is represented in 0 or 1 forms, which are the machine instructions. The languages that come under this category are the Machine level language and Assembly language.

The high-level language is a programming language that allows a programmer to write the programs which are independent of a particular type of computer. The high-level languages are considered as high-level because they are closer to human languages than machine-level languages.

When writing a program in a high-level language, then the whole attention needs to be paid to the logic of the problem.

A compiler is required to translate a high-level language into a low-level language.

And if you want an example of object of object oriented programming you can check out wikipedias example here: Object-oriented programming - Wikipedia

So onto the basics:

Parents:
So Luau works like a hierarchy system, think of game as the king and everything below it is its servants, now lets take for example workspace, that would be the noble of the king, serves the king directly, the parent of it is game.

Now lets say the noble has a child aka a knight under it, that knight serves the noble and nothing else, and so on.

Difference between locals and globals:

A local is defined with local in front of it, these can be used anywhere in the script, it doesnt matter where, and a lot of people have a lot of different methods for coding.

A global can only be used outside of a function in the main script, they can be used for functions but the game wont like it very much.

an example script:

ReplicatedStorage = game:GetService("ReplicatedStorage") -- this can also be written as local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- GetService basically is finding the classname of something under game, just game.ReplicatedStorage can be used too but if someone changes the name of it, it will not work

function Print_Not_Like_Roblox(str: string) -- str is the thing being passed through, and string is the type of thing the value is
    local string2 = ("hi guys: ".. str)-- hi guys is being said, and .. adds to it, this can be done infinitely, you can also not just do string2 = ("hi guys: ".. str) because its a function, now if you're setting string2 to something else say like string2 = string2.."EE" thats setting a value 
    print(string2) -- say if i run Print_Not_Like_Roblox("ooga booga") it will print "hi guys: ooga booga"
end

Whats with ==, +=, ~=, and =?

These all mean very different things, but have all the same premise.
== is checking if
= is making or setting something
~= is if anything else than
+= is adding to a value which would be the same as value = value + value
-= See above

What are functions?

Functions is code that can be ran multiple times like if i wanted to print something or check something i would do

function ReturnType(thing)
    return type(thing)
end

GUI = Instance.new("ScreenGui")
thing1 = "HI"
thing2 = 2

print(ReturnType(GUI)) -- returns userdata
print(ReturnType(thing1)) -- returns string
print(ReturnType(thing2)) -- returns thing2



Now some of you are most likely asking, what is return???

Return just simply returns whatever you want to where the function was called so instead of printing a function id it prints the type of thing.

This page is not complete in any sort, i still have a lot to add its just hard to sit here and write paragraph over paragraph

12 Likes

It’s a nice tutorial for beginners, but since most new Roblox developers have no programming knowledge what so ever, a method like print() could be foreign to them, although most of them probably looked at the developer hub and saw some stuff there. Still a pretty good tutorial!

3 Likes