Luau Intro
gonna be posting some of my scripts later and I wanna give y'all a basic introduction to Luau(the coding language used in Roblox Studio) <- (it's what Andrew coded his games in lmao :D that's why he's on the banner)
For those who are completely new to coding, I'm gonna leave some basic definitions here for the terms I'll be using in this guide. Up first, we have:
Variables: As the name suggests, these are pieces of data that are capable of changing or varying.
Constants: These are pieces of data that do not change at all.
Nil: Put simply, nil is the data representation of nothing or nothingness.
Booleans: A simple true or false data type. It can only ever be true, false or nil.
Local: This is a keyword that you put in front of a variable or function to tell the system that it's only gonna be used in that one specific script. If it doesn't have this keyword, then it's global, and can be accessed and changed from anywhere.
Strings: This is a string of characters! Strings are contained inside three different types of quotes: single quotes ( ' ), double quotes ( " ), and backticks ( ` ). A single quote can be contained within a double quote and vice versa, but a quote type cannot contain its own quote type. For example, you couldn't say:
"Fred says "hi!""
but you could say:
'Fred says "hi!"'
Backticks are a little less simple; They are used to allow the incorporation of variables in your string. For example, if you wanted to say hello to someone, but the name was a randomly generated variable, you would use backticks like this:
`Hello {name}!`
Backticks allow for dynamic messages and warnings in professional systems :3
Functions: A definable method through which a script or program processes data. For example, if you wanted to make a function that would square a number, you would define that function as:
local function Square ( x ) return x * x end
Every function has an input and output. The input consists of arguments, which are defined whenever that function is called inside of the parentheses next to it. For example, if I wanted to use that Square function, I would say:
local number = Square ( 8 )
Which would give us 64. We could then call it again using that new variable, like this:
local cooler_number = Square (number)
And it would give us... uhh.. um.. whatever 64 squared is!
Tables: Organized containers for data!
Tables have three primary variations: Dictionaries, Arrays, and Libraries.
All tables are accessed via keys. You can think of a table like a hallway— each entry in the table is a door, and the key opens it and allows you to access the data inside.
Every table is surrounded with braces { }. Everything inside those braces is within the table. Here's an example of a simple fruit descriptions table:
local fruits = { apple = "Red or green, whichever suits ya!", orange = "I hear it makes great marmalade.", banana = "All the potassium you could need." }
Whenever a table doesn't have a bracketed key, we get it using a path like this:
local apple_description = fruits.apple
This means that apple_description is now "Red or green, whichever suits ya!"
Dictionaries have keys that contain strings, numbers, or other specific types. These special keys are surrounded by brackets [ ]. If we wanted to use a specific key, like a string for example, we could do this:
local fruits = { [ "Apple" ] = "Cronchy...", [ "Orange" ] = "Yum :D", [ "Banana" ] = "Yemlow!!" }
Now, to access data, we have to use the corresponding key, like this:
local apple_description = fruits [ "Apple" ]
This would make apple_description "Cronchy..."
Arrays are tables that don't have visible keys. To access data from an array, you use an index, which is a number key. Arrays looks like this:
local name_array = { "Fred", "Michael", "Bob" }
To get an item from an array, you use that item's index, like so:
local first_name = name_array [ 1 ]
Because "Fred" is the first item in the list, first_name is "Fred".
Arrays technically accessed the same way that numbered dictionaries are, but arrays have their keys hidden and are formatted more like a list.
Libraries are tables that contain functions. They allow useful utility functions to be reused and shared across different scripts. For example, if I was making a Math library, it might contain functions like Add, Subtract, Multiply, Divide, Square, Cube, Factor, etc.
Making a Library is very different from making a regular table, because it contains functions. Libraries are formatted like so:
local math = { Add ( x , y ) -> ( number ), Subtract ( x , y ) -> ( number ), Multiply ( x , y ) -> ( number ), Divide ( x , y ) -> ( number ) }
It's a fairly advanced concept, you don't have to fully understand it right now. Just know that it exists :3
Types: Types are, well, specific types of data. They can be assigned to a piece of data using type definitions, which look like this:
local word : string
The most basic types are string, number, and any. You can define your own special types by using the type keyword, like this:
type dictionary = { [ number | string ] : any }
That line in between 'number' and 'string' is called a vertical pipe; It represents the word "or" in a definition. So, in our dictionary, the key can be either a number or a string! We can then later assign that custom type to a variable/table/constant, like this:
local user_info : dictionary = { [ "Fred" ] = "Some guy I dunno", [ "Michael" ] = "Description here.. heh", [ "Bob" ] = "Fuckass hair cut /silly" }
Roblox Studio has a lot of built-in types and classes that we won't get into, but the official documentation can be found here :)
lmao thanks for reading all that ik its a lot, reach out if you have any questions(feel free to put them in the comments or my ask box, I'll be happy to answer).

















