Welcome to the complete Roblox scripting course this course covers everything needed to build a fully functional game in Roblox Studio using luup no experience is required by the end of this course you will have built a complete game with core systems that every Roblox game needs to succeed I will show you everything from data saving to developer product integration and key Concepts and by the end of this Course you will have a fully fledged Simulator game to publish on all platforms we will teach you how to use a UI element scripting as well as a
fully functional battling mechanic the curriculum starts with a fundamentals of Lua before progressing on to more advanced topics like objectoriented programming we also create a bunch of UI elements for you to use in all of your projects we're also go over client server communication with remote events And remote functions we'll show how to Tween elements in the screen we'll use module scripts to maximize modularity and compatibility and each lesson includes structured exercises to re Force learning with over 250 coding challenges in total the course structure is available below you can go to timestamps as needed
let's get started in programming hello world is the traditional first program to write it simply prints the text hello world to The screen this is a simple code example I'm going to give you our first exercise our first exercise is to to write a script that prints welcome to Roblox to the output let me know when you're done here's the solution we're going to type in welcome Roblox this is our first solution and how you would print welcome to Roblox comments are lines of code that are not executed that are used to explain the code
this is an example this A now I'll give you another exercise WR a script that includes a comment saying this is my first script and prints hello Roblox okay we're back create a comment and say this is my script now we're at exercise number three we're going to remove these now you can write multiple lines of code each line is executed in order this is a simple code example of what I'm trying to explain write a script that prints line one then line two and finally line Three welcome back I'm going to print line one
line two and as well three okay in Lua semicolons are optional they can be used to separate statements but they are not necessary write a script that prints hello and World on the same line using semicolon here's the solution print hello semicolon semicolon [Music] blocks are groups of statements that are executed together in Lua blocks are defined using keywords like do and N Here's our first example what I want you to do is I want you to write a script that prints start then inside a block prints inside and finally prints end I'll let you
do it here is the solution okay so we're going to print start we're going to do do print inside then we're going to print n now identifiers are names given to variables functions Etc they must start with a letter or underscore and can to contain letters digits and underscores Here's an example of what I mean make a variable called myar then we print my variable what I want you to do is I want you to create a variable named player name and set it to Roblox user as a string then print it here's the solution
local player name equals Roblox user then we're going to print player name keywords are reserved words in Lua that cannot be used as identifier examples include if then else and Etc let's give you an example so if you did Local if equals 5 you can't do this because it's a if so the exercise I'm going to give you is is try to create a variable named if and set it to 10 and observe the air there's no code just an explanation attempting to use a keyword as a variable name will result in a syntax air
now global variables can be accessed from anywhere in the script while local variables can be accessed within their scope let's say we have a variable Called my VAR I am Global what if we wanted to do local local I local okay so here's the exercise I want you to create a global variable score set it to zero and a local variable lives set to three inside of a block print both inside and outside the block and just so you guys know a block is do so this is a block and if I want to put
something inside of a block and then we can run code in here like print local variable I'll let you do that and Tell me when you get back all right here's the solution so we're going to just rename this to score but we're going to set this to zero cuz that's a int value we're going to keep our due we're going to then do local lives equals then we're going to print score in this scope and print lives then we're going to print score this is the solution click play you can see it print 0
three and zero all right assignment is used to set the Variable of a value let's say we have a local X as our variable and it's equal to 10 then we do x = x + 5 then we print X the exercise I'm going to give you is to create a variable that's called health and set it to 100 then decrease it by 20 and print the new the new value all right here's the solution we're first going to type local health and we're going to equal this to 100 okay then we're going to do
Health equals Health minus 20 and then we're going to Print Health it's going to print 80 [Music] now let's talk about multiple assignments Lua allows multiple assignments in a single statement like this the exercise I'm going to give you is to set two variables X and Y to 5 and 10 respectively in a single line then print them okay here's this solution we're going to do local X comma y 5 and 10 we're then going to do print X is going to print five and 10 all Right statements are complete units of execution in Lua
they can be assignments functions calls Etc now I'm going to give you a exercise write a script with two statements one that sets a variable greeting to high and another that prints it we're going to do local greeting and we're going to change this to and then we're going to print the greeting blocks can be used to group statements they can also be nested like this this is a block that's nested Create a a nested block structure an outer block that prints outer start an inner block that prints inner then an outer block that prints
outer end and let me know when you come back here's the solution print outer we're going to do do it print okay then we're going to print outer n it's good to know how the syntax Works expressions are combinations of values variables operators functions that are evaluated to produce a value Like so this is a expression I want you to write an expression that calculates the area of a rectangle from width four and height five then print it all right here's the solution local width four like I said local height equals five like I said
local area equals width time height and then we're going to print area and that's the solution [Music] operators are symbols that perform operations on value Lua has arithmetic Relational logical Etc like this for example and then if we print some it'll print five the exercise you're going to use subtraction operator to subtract seven from 10 and then print the result here's the solution we're going to do result local result and we're going to do we're going to do minus 7 and then we're going to print the result and this is going to return three operator
order in which operators are evaluated so let's say we do local Value equals 2 + 3 print value this will print 14 I will want you to write an expression that adds five to the product of two and three and then print it here's the solution we're going to change this to result and we're going to do 5 = 5 we're do plus 2 * 3 but in parentheses okay as you can see here and we're going to print the result which is going to be 11 parentheses override operator president like so okay So I
want you to use parenthesis to ensure addition happens when before multiplication in the expression 2 + 3 * 4 and then I want you to print it and honestly this is the solution so if you already if you already thought this was the solution this is the right solution now unary operators act on a single aurent let's say we make a negative in Lua you can use it with negative as a negation ne5 print negative this is how you create a negative variable but what I want you to do is I want you to create
a variable called positive and set it to 10 then create negative as its negation and and print both here's the solution we're going to do local positive equals 10 we're going to do local negative equal netive positive and then we're going to print positive comma negative it's going to print -1 and it's also going to print 10 this is the solution the concatenation operator is going to used As dot dot let's say we create a first variable and also a second variable with hello and world then we want to combine them all we got to
do is do go combine equals first dot dot space do do second and then we print combine and this prints hello world what I want you to do for this exercise I want you to concatenate Roblox and studio with the space in between and print the result let me know in your back all right here's the solution instead of doing Here let's say we wanted to do Roblox studio and to combine them we just combine them both right here and then we would PR the full expression the hashtag operator is the operator that Returns the
length of a string or table let's say we want to return a string called hello we would use the print hashtag string to print the length of the string in number what I want you to do is I want you to create a string Lua and I want you to print its Length all right so you all you would do is you would change this to Lua and then you would also print the the string and it's is a PR of Lua which is three characters the type function Returns the type of value as a
string let's say we do local number equals 10 we print type this is going to print number what I want you to do is I want you to create a variable called is true and set it to true and print its type here's the solution let's do local is true we're Going to set it to true and then we're going to print type it's going to print Boolean try for yourself variables are declared using the local keyword followed by the variable name let's say we do local my variable and then we do myar 10 print
my VAR the exercise is to declare a variable player score and set it to zero and then print it create a local player score with a with no value and then all we got to do is do score zero print Player score Lua is dynamically typed variables do not have types but values do this is a number and this is a string and this is going to print the variable the exercise is to set a variable item to five and then change it to five with words instead of instead of a number and then print
it each time let's go over the solution local item equals 5 print item is going to return five then we said item five and then it's going to Print the word five instead of the number okay now nil is a type with a single value nil which represents the absence of a value let's say we created a local variable called nil and we printed it it would return nil what I want you to do I want you to return a variable declare one called user input and send it to nil then print it so let's
do user input nil print variable which is user input and this is going to print Nil booleans are true and false here is a simple code example let's say we the local is playing print to return true what I want you to do is you want you to create a variable called is game over and set it to false and print it here's the solution is game over and then print is game over numbers in Lua are double Precision floating Point numbers like local pi equals 3.14159 print I want you to set a Variable gravity
to 9.8 and print it 9.8 change this to gravity and also make this gravity that's the solution now strings can be defined with single or double quotes let's do local greeting hello print greeting I want you to create a string named game name and set it to my game and print it let's say local game name equals my game and this is the solution print game name Escape sequences like sln new line can be used in strings let's say we do Print line one back slash line 2 what I want you to do is I
want you to print first line sln second line to display two lines so adjust this as you like it so what I would do is I would do first line and then I would do second and that's how I would do it now multi-line strings can be defined using local multi and using double space square brackets like this line one line two and then we can print multi line the exercise I want to create a multi-line String with hello the first line and World on the second Ben print it here's the solution hello world it's
all you got to do the scope of a variable is the region of code where it can be accessed like this as an example inar and that's pretty much it if we were to print inar it would air the exercise is declare a variable inside the a block and try to print it outside the block attempting to access a local variable outside of it Scope will return in an err Global variables are accessible from anywhere in the script Global VAR I am Global function test and then we'll print Global VAR in here and then we
will run the test function out here this will print I am Global as you can see what I want you to do is I want you to create a Global variable max players and set it to 10 then I want you to print it from within a function max players here's the solution and we set this to without any String function print max players we're going to print the max players then we're going to run the function print max players let's go on to data type Lua has a single number type which is the double
Precision floating Point local integer is five local float equals this a 5.5 and if you want to print them we can do print type integer comma type both are number what I want you to do is I you create two variable one integer and one Float and print their types which we just did but I want you to type in just so you know how to use it next strings are sequences of characters let's say we created a string local equals Lua type going to print string I want you to write this again create a
string variable and print its type so here's a solution my string equals Roblox and then we're going to print the my string as the type going to print as String Boolean types have two values true and false like local bu equals print type you can see we just put Bull in here and for your exercise you're going to create a Boolean set it to false and print its type so is and we'll say false this is the solution that we're going to print is false it's going to return Boolean the nil type is a type
of a single value which is nil local nothing equals nil print type nothing this is Going to print nil I want you to set a variable to nil and print its type that's the solution now functions are first class values in luup that can be stored in variable here is an example of what I mean by that so let's say we print the type of the function this will return function it will print the word function to the console what I want you to do is I want you to define a function that prints a
roblocks and store it in a Variable then print its type let you do that all right here's the solution we're going to create a function called local my function we're going to set this to function print row block print type my function and this is the solution tables are the main data structure in Lua used for arrays dictionaries Etc and here is a simple code example I want you to create an empty table and print its type what I would do is I would do table and then Print my table user data is a type
for arbitration C data often used in Roblox for objects here is a simple code example local part equals instance. new part print type part here's your first exercise I want you to create a new part and print its type local new part equals instance. new print type new part this is going to print user data threads are used for Cor cortines in Lua this is a thread cortin do create Function print type cortin this is going to print thread I want you to create a cortin and print its type my code here's a solution and
we just print my Cod Lua automatically converts between types when necessary this is called type conversion you can also use functions like two string n two number like this local num equals 10 local string equals two string number and local and print type string what I want you to do is I want you to create a number to 42 and a String and then print its type so all I do is I would do number is 42 string is going to do string to the number and then we're going to print the number the string
you can also use the type function to check if a type of a value so let say we do local value equals text and we say if type if statement value equal equal to string then we will print it's a string I want you to create a variable set it to 100 and then check if it's a number printing number if true All we would do for the solution is set value to 100 check if it's a number and [Music] number next is is arithmetic operator arithmetic operators include plus minus division multiplication exponential and modulus
local a = 10 local Bal 3 print let's say a plus b and the different ways you can do this are a minus B A * btimes a divided by B and also we can also do a is modulus as well as exponential print the result of 5 * 2 + 3 here's the solution print 5 * 2 + 3 relational operators include equal equal not equal greater than equal to less than equal to greater than and less than so let's say we have local Y and local X we do local y we print xal
equal Y and print X is not equal Y and this is going to print true and that the first one's going to print false and this is going to print is X less than y and it's going to print true because it is less than y what I want you to do is I want You to check if seven is greater than three and then print the result all right here's the solution print 7 is greater than this will print true logical operators include and or or not and this is what I mean by that
print A and B going to print False A or B going to print true print not a is going to print false what I want you to do is I want you use the exercise to use and to check both if five is less than three and two is greater than four are True then print the result here is the solution print 5 is less than three and 2 is greater than four this is going to print true now decision making the if statement executes code if a condition is true so if I am older
than 18 then I will print adult now else is a way you can clause and execute if the if condition is false so now talk about the Els if it allows you to check multiple conditions we can say Els if the age is Is greater than or equal to 65 then we could say print you are retirement age here's your next exercise I want you to write a script to print the day of the week based on a number 17 here's the solution local day equals 3 if day is equal one then I will do
print Monday okay else if if day is equal to day two I will then print two Tuesday right you get where I'm getting here and then if I do else if 3 day is equal equal to three then I will print W Wednesday and Continue for the other one so Friday Thursday Saturday Sunday and there we go so they are if statements that can be nestled inside each other so let's say we do loal x equals local y 20 if x is less than zero then Y is less than zero then and then we'll do
print both are positive this is a nested if statement what I want you to do is I want you to check if two numbers are both greater than 10 and print both large so what you would do is you would do greater than 10 And then if Y is greater than 10 it will pay both are large easy right now let's talk about how you can use for Loop for Loop iterates through a specific number multiple times here is a quick code example example this is going to print five times each number what I want
you to do is I want you to use a loop to print even numbers from 2 to 10 and let me know when you're back so I can show you the result so all you would do is you would edit this to say 2 10 And two what this will do is this will print two but it will print in twice so it wouldn't print every time for each number it will print every two times so if we print I will print 2 4 6 a repeat until Loop repeats print I repeats until a condition
is true okay so this will be until this is true it'll print until I less than 5 now here is the break statement The Brak statement you exits the loop Prematurely let's say we have a loop a nested for Loop like this do and then we say if I is equal equal to 2 five we will do break which is going to break and exit the loop prematurely then we'll print I use a loop to print numbers from 1 to 10 but break when reaching seven let me know when you're back all right all you
would do for the solution is change this to seven and that's pretty much it Lua does not have a continue statement local I equal 15 we say I is Not equal to three then we will print I now this will print numbers from 1 through five skipping three now an infinite Loop runs forever unless broken and this is a infinite Loop and this is a way to use weight to wait for the computer I want you to print hello every second here's the solution print hello world or hello like I said and then wait this
is the solution now looping through tables you can use pairs Or I pairs to Loop through tables here is a local example local tb1 equal a = 1 this is a table comma b = 2 and C = 3 okay we'll do four key value in pairs tb1 do we'll then print key and value I want you to create a table with three elements and print each key value pair which we just did but I want you to write it out again so you get this mastered now the numeric for Loop iterates over a range
of numbers let's say we do 4 I = 10 negative one you can print I that's pretty much what you do and this is use this is using a loop to print numbers from from 10 to one in Reverse now the generic for Loop can iterate over iterators so if we do i v in I pairs which is going to basically mean the I stands for Index this the fentor value so in I pairs I'll put a table in here so one two and three and this is the iterator inside of here okay and then
we'll put do and then we'll print index And print value and that is how you do it and that is how you use iirs to print the indices and values of an array 1 2 and three here's how to define a function let's create a function called say hello then we print hello then we run the function by saying print hello now functions can take parameters what is a parameter parameter is in our parentheses so let's say we have a and b and we change our function name to add Then we change this to a
plus b then we just run the function add 3 comma 4 now what I want you to do is I want you to write a function multiply that takes two numbers and prints their product here's the solution let's say we have a function called multiply and we have X and Y we print x times y it's that easy right and then we use the multiply function to then do five and six as an example and that is how you solve that okay Functions can return values using return let's say we want to return x *
X and we can do the square of X we could do local result equals square and then we print the result and this will return 16 want to know why because the square is 4 * 4 what I want you to do now is I want you to write a function that's called Cube and return the cube of a number okay here's the solution we're going to change this to cube we're going to put number in this parameter we're Going to return num but we're going to do that exponential and we're going to return we're
going to print we're remove this part we're going to print Cube what would this print it'll print 27 because this is the exponential there's multiple return values functions can return multiple values how we do that function min max okay A and B we'll do if a is less than b then we will return a comma B okay else we will return B comma a and then we will do this and come down here Local Min comma Max equals min max this is spelled wrong you was case sensitive print Min and then Comm Max it's going
to to print uh three and then five as you can see over here because as you can see it's greater and it returns whatever we printed now I want you to write a function that returns both the sum and product of two numbers here's the solution we're going to create a function called sum prodution production X and Y we're going to return the X + Y And then we're going to do comma x * y like I tried to explain now we're going to low down here and do local SP p 4 comma 5 then
we're going to print S and P as going to turn nine and 20 functions can be local meaning that they are only accessible within their scope okay here's a simple code example this is going to be a print private and then we will try to run the private function now what I want you to do is I want you to define a function local Function called secret that prints hidden and call it so all you would do is use secret as a function print hidden and Define the secret function there's a thing called Anonymous functions
functions without names that can be assigned to variables how would we do that well we can do local function equals function this is a Anonymous function with no name okay and then we're going to print unknown Anonymous okay then We're going to print the function that is how you use those kind of functions [Music] functions can be passed as arguments to other functions let's say we create a functional function apply function comma X return function okay and then we can go into a local function Double Y then we return Y is two then we will
print apply okay then we'll do double comma 5 is going to print 10 when to know why because it's going to apply X to Y to Double so we'll double the function and this is going to return the double of whatever this value is so this is 10 will be 20 to do 10 and that's pretty cool what I want you to do is I want you to write a function that's called execute that takes a function and then calls it here's a solution function execute we'll we'll run F in this function and then we'll
do local function say Hi and then we're going to do print then we're going to execute say Hi okay and this will print hi functions can capture variables from their enclosing scope let's say we make a function called make counter and we we make this an empty function with no parameters local count equals zero return function okay and then we do count equals count + one okay and we return the count okay and then we go local counter equals make counter they print counter and then also print counter this will print the first print Will
print one and this one will print two now what I want you to do now is to create a function that returns a function to add a specific number here's the solution we create a function that's called Adder we return the function and then we put return X then we local add and we put n here we put X here we do local add five and we'll do make adder and put five in here then we will print add five 10 and this going to add five 10 so this is going to print 15 Functions
can accept a variable number of arguments using three dots so dot dot dot so let's say we make a function called sum we put dot dot dot here we can then do local total equals z now we'll do four comma V and I pairs then we're going to do this we're going to do dot dot dot do then we're going to do total equals total plus value then we will return total and then we will print print sum 2 and three this will print six because all these numbers add up Together and this is how
you would use it to add up multiple numbers together the exercise I'm going to give you is to write a function to find the maximum of any number of arguments how we do that well let's change this function name to Max now we're going to put dot dot dot in here we'll do equal to dot dot dot we'll do local max value equals args then we're going to do a for Loop in I Pairs and we're going to put our argument In here okay args and then we're going to do if V less than Max
Val sorry greater than Max Val we will then do Max Val equals V we'll end and then we'll return the max Val then we're going to do the max So Max and then we're going to do 3 7 28 and now what do you what do you think this does well it prints the biggest number so it's going to print eight okay [Music] tail calls allow functions to call other Functions without growing the call stack if we going go over here we do function torial n account equals account or one if n is equal equal
to zero then we return count else we will return factorial n minus one and times the count factorial five so print 120 [Music] and there's also a thing that's called tables we all to find an empty table by doing local my table as well as a dictionary like table so dictionaries Are cool dictionary table Roblox year 2006 excise I want you to do is I want you to create a table with keys color and size and I want you to set to red and 10 and I want you to print the color what I would
do is I would change color to red right and I'll do size and then what I'll do is I'll print the item this is going to print red tables can have both array like and dictionary like Parts like this like local mixed equals 3 and then key equals value now I should Create a table with elements four 5 and six and a key L label and then set to numbers to do that we'll do four change to four change this to five and change this to six and I will make a label called numbers there
we go and now all we got to do is print table with a one parth that's table one value and we'll print mixed table. label it's going to print four and it's going to print number so we click play tables can be constructed with initial values as well Table called local colors and we just name it values like red blue right green right all right let print colors here two in here it's going to print blue the second option now if you want to create a table that has that's named fruits and you want to
P your favorite fruits in there and then print the third fruit try a table length we just do this we do keep our colors we then print colors right console prints three because there's three values here we can Also insert into tables let's say we want to insert something new into this colors table we can say table. insert colors because we want to insert into colors table and we'll say orange that's how you insert it and then we can print the table and it'll print the fourth option it's going to print Orange orange see right
here how do we remove from tables we use table. remove okay and we can use that to remove red okay then we can print the first option and that Option is not going to print because it's a string so if we wanted to remove that we would use a one two and three ches two colors then we just change it to one one you can see it prints two because we removed it from the table we can also uh use pairs to iterate over all key value pairs in a table let's say we have this
we have a set to one and C set to three okay let's say we have a 4K key comma value in pairs and then we do Do and we print key and value what is it going to print well it's going to print A1 C3 and B2 what if we want to do it in order well we can use the I pairs function so let's say we have three things in here like one two and three right we could use I index and v in pairs and we can do local colors we can print the
I and print the V now it's going to go in order so one one 2 two 3 three okay now I'm going show you string. uper and string. lower okay so Let's say we have a local string hello then we're going to print upper this is going to print hello but in all caps we can also do print string. lower which going to print all in lowercase which going to be hello in all lowercase now string. sub is used to get a sub string what do I mean by that well if we had a string
called hello world and we wanted to get just this hello part we would do string. Sub sub and we would put the numbers we want to Put in here so let's say we want to we first want to do string. SUB okay then we put string in here as well as taking out whatever numbers we want so let's say we want only the first five okay okay we'll do one one comma five this is going to print hello only you see it only prints hello okay now you see in put hello there's a thing called
string. find which is another way to do it so string. find is to use to find a substring okay so now if I want to find A position of an object we can just do this we do string and then we can do to find it we'll do let's say we'll find World okay now this will find in the there so if we click play it'll print 7 through 11 so that's how the that's the letters it's amount from what point the world is at this is used for finding things if you've lost them in
a game let's say for example okay we can also use string dog sub okay to replace substrings let's say we do world we want To replace that with Lua we could do this so we could do comma Lua now it's going to print the hello Lua see as you can see here cool right so that's how you would print with G sub what about if you wanted to use string. format well go back here string. format it formats strings so let's say we have a Roblox and we have a local num equals 2006 we format
this and we say let's say we want to say percentage was no sorry quotes Percentages was launched in days okay so we put string here and then we also put number here okay we put play Roblox was launched in 2006 that's how you would basically use format to format strings in the proper way now there's a thing called string. rep okay we can remove this string and we can we can also do ha okay then we can come here and just rep and we do string comma three this will repeat three times so Play ha
haa okay cool now you can also use string. match so string dot match okay you can use patterns with string on Match to find matches so let's say we want to find matches in hello one 2 3 we want to do that we do string and we can do this and we can put percentage D+ now we can print the numbers of this okay and this will just find all the numbers in there and print them so as you can see if we C play it's going to print one two three okay I was trying
to make this A variable so we made this a variable like local numbers equals this and we just remove the print you do this and you can see one two three okay and that's you use string. match okay and that is basically a lot of information that you have digested but there is still more this video is not over yet but you've gotten very far so congratulations you're about halfway done with the video okay or a third away there but that's that's all Right now we're going to go over the most important part actually making
a game okay now making games is like pretty easy but for me after you get used to it but I'm going you exactly how to do it okay now going to go over some Advanced topics that most people don't go over when they go over a Roblox tutorial okay so just you know we're going to go over the math properties now okay I want to give you an exercise because I've already showed you a lot of Stuff so replace all vowels a e i o u in hello with a asteris and print the result here's
the solution I'll start with local string equals hello okay then I'll do local new string equals string G sub remember using this yeah you remember using this now string and then we'll do it'll put quotes brackets and then we'll put it here a e i o o u and then we will replace with the asterisk symbol then we will print the new string and this will print hello but with Asteres in all the e and i us all righty here's another exercise count the number of words in though this is a test test and print
the total pause and try it here's a solution I'll type local string equals this is a test okay local count equals zero then we'll loop with for in string. gmch string and then we'll do percentage s+ and then we'll do do count equals count + 1 end then we'll print count okay here we go that's a solution now let me give you another exercise I Want you to format 1 2 3 4 5 with commas as 1 12,000 comma 345 and print it pause and try it all right here's the solution I'll set local number
to 1 2 3 4 5 six okay sorry and then I'll do local string equals string. format okay I talked about this before percentage D okay and then we'll do number colon reverse okay we'll reverse it and then we'll also use the G sub and then we'll also come down here and do percentage D percentage D percentage D Okay and then we will do the comma okay comma and still on the Block and we'll do percentage percentage one and then we will do comma in here and then we will reverse okay see that all comma
at added right there yes that's exactly how to do it then we will print the string if we click play you can see it prints 12,000 345 okay great now that you understand that let's talk about concat okay let's create a table with a And also B then we'll use print. table. conat t+ okay it's going to print a plus B you can see right here A plus b cool all right now I want you to set a variable I want you to catenate 1 two and three with a minus sign and print it okay
let me know when you're done all right so I'll set local T equals 1 two and three I'll then do print table concat T and then I'll print the minus sign okay you got to print 1 - 2 - 3 okay now there's A thing called table. sort which is really important okay so let's say we have a strings in here one two and three but they're at strings right let's do table. sort T okay then we'll print table. concat okay we'll put T and we'll put space here it's going to print X Y and
Z all with spaces as you can see right here one two and three okay now how do we remove the first element let say we want to remove one well we can use table. remove T Comma one and then we can just print table concat T there so two and three we removed it from the table now now what if we wanted to access a object in an EST table and and with use multiple key accesses well local tal xal y with a of course a bracket as you can see it's getting more complex now
but as you can see here if we do y equals high and we do this this is a nested table okay we print t.x doy and as you can see it's going to print high high okay now I know I'm getting a little bit complex here but this is what you watch this video for you don't want to get some basic tutorial okay this is why I'm going over Advanced things now you're far into the video you need to know about this stuff because this is this is informational this is going to help you out
someday so next we're going to print the length of local T so let's say we're going to make a table with let's say we have it one two nil and four right to print it we'll Just do print #t it's going to print the length so we play it's going to print four because we have four variables here now I'm going try to count to five with while true okay so let's do while true do okay let's do IAL I + one okay then we will do print I and we'll do Let's do let's go
Define I equal 0 okay so now we have this right after we print I we're going to do if I is greater than or equal to if I is greater than or equal to two then break end okay that's going To print one and two as you can see right here cool right so now I want you we're almost done but I want to go over a little bit more of how to actually use Lua okay we already went over our strings inserting tables everything like that now there's a few things that are robloxs related
that I want to go over okay so there's a thing called instance. new okay so local part equals instance. new right and we'll do part and we'll put it inside of workspace Well what is workspace how this code run well this code is going to run and put a part in a workspace as you can see yep cool so play you can see it enters a part inside of workspace right here it's in the middle of and Center so if we delete the base plate you can see no no you delete the spawn you can
see there's a part right there okay so as you can see now that's how you use instance not new inter any parts it's also way you can also do anything from from anything Like sparkles anything all the objects are in this it's this not new f okay so let's say we make change of brick color so part. brick color right equals brick color do new this is a way to change the brick color and we'll change it to bright red okay all right then we can change the part opposition as well on any other properties
of any object with instance. new as well as Tak the position Vector 3. new this is the way you change position with Vector 3. New okay all right and this is going to make the part red okay so if you click play you see right here click play see there's a red part or if we delete the spawn you see there's a red part or we on red it's as you can see it's red so I can't delete it for some reason but if we go to part you can see it says it's oh here
so you can see it's a red part okay and that's how you use instance. new I'm going to show you how to use player added player added detects when New players are joining in Roblox game. players. player added connect function and we'll put player in this parameter here okay okay then we'll print I don't know why it's doing this to me name okay and then we'll end off okay and say you use a player added event okay now I'm going to go over tweening now okay so tweening is pretty simple okay so tweening is when
you go to here so tween service animates Properties so let's do local tween service okay equals game get service get service and we'll do tween service tween service is a way for you to animate objects animate things animate guis Lo go Parts equals instance. new part okay workspace okay then we'll do a local tween to define the actual tween we'll do tween service okay create okay and then we'll do part as a tweening object tween info okay do new just the property of of this time as Well as add the size of the amount of
size we want to change so Vector 3. new we're going to make it a little bigger so five by 5 by five and then we will also then play the tween by doing tween colon play okay and this you would use a tween to Tween AP part now there's a thing called do touch we can use so local part equals instance. new part inside of the workspace okay which the workspace is right up here okay now we're going to do part. touched okay Connect function hit okay and then we will print print hit. name okay
so going to print the character's name so click on here we go to a part it should print the thing that we clicked so it's right here so we CLI spawn location we delete this or we move it let's see we move it as you can see it's going to tell us what body part has touched the part okay okay cool now there's a thing called tools thing called starter pack well we can change this to Tool okay and we can Do instance. new is a tool right so let's say I want to add a
tool in the works in the game. starter pack starter pack is a place where all the gears are store as you can see if we go down to starter pack it's right here okay so starter pack and then we're going to then do print and we're going to PR hit. parents. name okay part. touch connect hit okay now we also change change the tool Name by doing tool. name to equal to knife okay all right it's time to get Into the math math. A10 Returns the archit tangent in radians so print math. aan is one
okay it's going to print you'll see I don't know the exact math you see it's going to print 0.78 blah okay now what I want you to do is the exercise is print the arkent of zero okay it's going to print zero because it's zero right so zero and as you can see if we print it's going to print zero cool that's your exercise pretty simple right well now we're going To use a thing called math. square root so what is math. square root math. sq ft 16 this is going to print four wait I
did it wrong math. square root square root sorry four now try doing a different number and tell me what it says 25 is five cool all right now there's a thing called reverse string. reverse okay reverse and we can reverse a string High okay it's going to put High backwards all right now next step is to do a little bit more math now so Let me just show you what I mean this is one of our final exercises before we are done for the night and I think we have done a lot of stuff and
this is the final most important thing about Roblox Lua and that is actually math. r random okay now let's say I want to make a math. random seed is 10 right and we print math. random okay 1 through 10 it's going to print a consistent value so 7even it's going to print it every time so Seven seven it's going always be consistent goes use math. SE so we click this out see going to print four now the math. randomy makes it different than time but this makes it the same every time as you can see
if we just do that as you can see it's the same every time cool now I'm going to use how to use math. floor so math. floor is a few things you can round down or up with seal okay math. floor and we just put a number in here Like 3.7 it's going to print three because it's going to round down see three and we want to use math. seal okay seal going to print four as you can see right here okay cool let's talk about math. cosine Co put zero in here it's going to
print one okay cool there's also thing on math. Pi so let's do math. PI ID by four it's going to print a number I don't know the exact number but let me see 0.70 that's that's that's a math. pi Divided four so what's 34959 whatever negative 1 cool all right now there's a thing called math.log it's as well so math.log and we'll do math. it's going to print one okay let's see uh and that is the complete Roblox Lua course hope you found it great and I will see you very soon thank you for watching
subscribe thank you now here's part two that I promised of showing you how to make a Simulator Game I will dissect this Simulator game and show you everything that's made in so let's first start off with text chat service sound service or player script now let's go over everything I've talked about and why it relates to anything about making a real game since you sticked around now versus the trampoline script as you can see this is going to basically control all the trampolines now I've talked about touched events T hit. parent talked about all this
stuff We're finding a first child of humanoid we're waiting and we're also getting a property of a humanoid we're adjusting all these properties here and then we are connecting all trampolines with ey pairs like I just showed you in that pretty short tutorial now trampolines is going to trampoline all the places so all these are trampolines I'll show what exactly what I mean see right here this is a trampoline Okay this is a trampoline if you jump on it it go up And that's what that script does okay next script to dissect even further okay
so next script is the music script this was not written by me as you can see it's print by somebody else but this is a basic music script that defines the variables um it checks all the music IDs and then also plays the music and then lets it pause it through a button that's what that is okay we also got landmines this is the script that I wrote for landmines so they move the parents move Them explode them up higher and then I connect them all as you can see I've went over all this this
is why I'm giving you all the sauce because at the end of the day all this matters is to show you exactly how to make game and that's what I've just showed you so everything you just watched is used in Roblox games we can use Game Pass controllers it's going to be using as you can see is self you might ask what is self self is just referencing the Script itself now let me just explain the easiest way to explain what self does see this local Game Pass controller right this module script you're defining it
you're also adding different properties tables here right you're then using this self to Def to find the variable game pass this is a function we're using a parameter called owns game pass that we can call later in other scripts not just for this script that's why module scripts are so helpful next We have the data receive controller okay and this is going to receive the data and load the player data on join with data service okay data service service is the packages folder we just installed on data store okay with nit we have the chat
service messenger local player is also a thing you can use on local scripts only it's a way to reference the exact player we also got some other stuff like loading screen on enable that's a way that's a property of all Guis elements that's a way to disable or enable something we also got let's say we want to go to Left bu's controller well you can do that easily by setting the balce effect making them all animated that's how you were able to animate it's always able to animate all these objects here as you can see
click on this it animates this is super smooth super slick right and that's how you do that so then then we have an invite rewards button which is going to show an A prompt message when they invite someone right and then we have a group word controller that's going to be commented out and then also a clone controller okay and then also that's just all the game passes here and we signal an event and fire it now remote events are pretty easy to understand okay remote events are not used in normal Lu but they're used
in Roblox Lu remote events are like this let's say we want to create a request spectator event Or say I have a backpack event or we get let's say we just try something like let's say launch clones or that's called contrl shift F okay control shift F and we search for launch clones okay and here we go this is how remote events work okay this how remote events always work you first declare the variable with launch clones event say your remote event okay and then you use that event later on to launch the Clone so
when this event is fired on the on client Event we will then launch the Clones all right and then we will also o launch the Clones here this is the function to launch the Clones as you can see this is going to run when the event is triggered okay and here we go okay so now launch clones event this is the actual script that will actually launch the Clones okay this is the getting Canon ability that I've made okay all right so that's how you do that okay all right let USE events what about remote
functions well If we go here and we go follow reward we go to control shift F again and we do this oops control shift f as you can see we're going to Define our variable here so follow rewards as you can see is a client so on do client we will claim the reward okay and then we can use the structure so let's see what I mean let's see what I mean here okay now as you can see here all right it say use remote functions okay you define the function right TR re so I'm
going to use this in On client invoke okay this is going to run the get troll Target on The Spectator so it's going to pick the selected player and set the value to it that's how this works okay and as you can see here we use the get troll Target to invoke the client okay it's going to invoke the client so it actually knows which player to use the troll effect on okay and now we got to get the troll Target here and we use the same exact things in everywhere in here let a use
Remote functions and remote or events okay and that is exactly how you do it okay now I'm going talk about not talk about client now let's talk about UI okay I don't put any scripts in my UI I I put scripts in the server service okay so let's talk about server script this is my framework script it's created by me I don't want to expose that just kidding I don't care but anyways so this is a way to run all the modules okay and then start the mod okay this is how you Use that okay
and this is a soft shutdown script this is the source server I put everything in module script as you can see right here so everything's in module scripts everything's super modular like I said this is what your layout should look like when you're making a game okay you should always have it in this layout where there's a server script with a folder and there's also a client side okay and that is proof that you can make A game with everything I just taught you so go ahead make your games and tell me when you become
a millionaire all right thank you for watching and I will see you tomorrow or next week whenever you guys want me to be here I will be here for you anyways I'll see you soon peace