Transcript for:
Introduction to Roblox Scripting

yo what's good people it's aile here with my first ever video pretty excited to get into this you know I noticed a lot of Roblox scripting tutorials nowadays are kind of outdated so I thought you know what I think that's about time it's about time somebody updated the scripting scene and you know why don't I do it myself so this is going to be a pretty long series I'm presuming I I don't think I will stop it for any particular reason it's going to go for a while for a while because I do want to cover a lot of more advanced topics to help because back when I was learning to script I never got any advanced help with scripting and developing Frameworks and different methods of scripting I never really got in-depth tutorials of how to do that stuff I kind of had to figure it out by myself and that took a lot of time it would have been a lot better if I just had a layout you know that somebody who was experienced kind of already knew already to teach me how to do these things but nevertheless sit back aile is here to drop some wisdom bombs here but seriously welcome aboard in this video I'm just going to be introducing the concept of a script because after all this is a scripting tutorial a scripting Series so it's probably going to involve a lot of scripts but before I talk about scripts I think it's important how we approach scripting because triing can be seen as this hard topic or you know there's a certain way you have to do something or even what you need to know you know this was a personal thing with me is I thought I had to know everything about every single detail and that really just isn't the case the point of scripting is to give you a set of tools to help you build your game that that's fundamentally all it is but I would often find myself wondering like okay well why does this work what is the specific features of this function or this or this or this and really you just need to know how it works why it works just the surface layer you don't need to go so into detail unless you're like somebody who's into that I can understand that but we need to take this in steps there are certain things that I am going to Opus skate for a certain amount of time until it becomes relevant right because I think the best way to learn how to script is to just pick stuff up as we go you know I want to do this thing and therefore this thing is going to be very useful to us in scripting so don't want you to have a a fearful mindset or this feeling like you have to know every single aspect of everything it's a NeverEnding journey of learning so please don't be nervous about any of this stuff any of the stuff I'm going to show you please just trust me listen to what I have to say do what I do and eventually you know maybe 5 10 15 20 episodes later everything will just click there's only so much intuition that you can have about each topic I'm going to talk about until it just comes down to muscle memory so we all good we're all good all right let's go ahead and just open up a base plate here I'm going to presume you already know about Roblox studio if you don't I'm going to link a video in the description go watch that then come back and we're going to get right into it so first thing we're going to do is we're going to rightclick on this little service called a server script service now once again as I said you don't need to immediately understand intuitively what a service is but let me give you just a brief idea of what it is I'll give you some surface level intuition basically a service is kind the services are like the organs of the game and the game is really just the game that you make so if I you know highlight all of this stuff all of these services in the Explorer these are sort of our primary services and these primary services are the main organs of the game so I think for now that's all you really need need to think of it as server script service is basically a service that lets you put server scripts in them or in it and a server script is going to look like this it's going to have a little piece of paper with some drawing and it's going to say script make sure it does not say module script or local script it should say script click and we opened up our first script now do not worry you do not need to know what a server script is but you might be wondering what is this print hello world statement what is that well let's go ahead and delete it let's just cross that and then backspace deleted now I presume you should know how to run your game Let's click on that and you're G to have this little if you don't have this window output I'm just going to exit out of it go to view and then click on this button here output and I presume you already have Explorer and properties open because obviously like you need those two open but you notice all this jargon kind of came in here blah blah blah blah blah none of this matters okay that's not the point we're going to stop the game so now you have output open let's go ahead and write that statement that we got when when we first opened the script so hello print hello world I think it was this right I think so well actually let's just delete this so you can cut it right click cut it right click insert object script and you see we get the same thing so every time you open a script or sorry every time you create a script you insert it into the server script service or wherever I recommend you only put server scripts in the server script service because that's the most secure way of creating scripts and I will explain that in a very later episode but let's just remember just pound it in your head always put server scripts in the server script service always do that always remember to do that and for now the answer I will give you is it is the most secure way of creating server scripts once again you also don't need to know what a server script is that's fine but either way every time you create a script it's going to have this little print hello world statement and we're going to go ahead and just click inside of these double parentheses here and you can see it explains to us how all this works print string blah blah blah blah blah so it says it prints all provided values to the output any number of arguments to be outputed so you notice it says prints all provided values to the output the output oh whoopsie hold up okay there the output this is this is the output window so how is it going to print out well let's see let's run the game what's different let's see wait you see that hello world let's click on it it takes us back to our script so you're probably wondering what is the output the output is kind of like a messaging helper of sorts and it basically interacts with your scripts and prints out any information that's important and there are different types of messages from scripts that can be printed out but just take keyword takes information from scripts and prints it out but you have to explicitly put it in a print statement and why I said it prints it out but you have to put it in a print statement in your script and we can see once again it says print all provided values to the output so you're probably wondering what exactly is this format the way that I wrote this okay I understand what this does it prints out this hello world into the output but you're probably wondering why doesn't it print out the these why doesn't it print out the brackets why doesn't it print out any of that stuff and it's because of the format syntax syntax is kind of like the language that we're us using to describe what we want to do because coding isn't just English I'm sure you figure that out by now because this might not make any sense and that's fine you don't need to understand it let's break it down but first let me show you something so make sure that you have two double quotation marks right these two here make sure it looks like mine and you'll notice if I type out pizza for instance and I click run look what it prints out in my out put pizza okay let me give you a more practical example let me say this script isn't working this script is not working this is not we're not getting what we need oh I got it the script isn't working okay where is it oh I click on it and it opens the script that's a practical example and we're going to have to do that later on and I'm going to show you how later but that's kind of like a an introduction to a later episode so let's get into data types there are three main data types I want to introduce now if I don't know three four I don't know but let's let's write some stuff down here so the first one we've already seen which is a string right and you know this because it prints right here now let's say I just uh erase everything in here and I put the number five it's not string anymore it's number so I've just shown you two data types a string and a number a string is just text essentially that's all it is but you have to put it in between double quotations like a quote right I'm quoting Mark he said I like Pi I don't know but yeah you get the point double quotations indicate a string no double quotations in just a number indicates a number data type and if you think about it it's just a type of data data can be stored as a number it can be stored as a string which is just text that's how Roblox works and you're going to see why these types of data are more useful when you get more experienced for now you just need to know just get this in your head because these things are going to be very useful to you in your later in your scripting Journey oh yeah and I also never print out a number yet so let's print that out and you can see right here printed it out 53 425 53 425 so that's neat we can print out strings or text and we can print out numbers well what else can we do with this let me tell you something cool you can actually do math with printing but you might be wondering why is this formatted like this why are there brackets here those brackets are going to be common or what are called functions and inside of these parentheses are what are called arguments which are just the things that you want to be done with the function which is print now obviously you don't need to know what a function is right now because we're not talking about functions I will go over that explicitly in a separate video but specifically what this function is is it's called a vartic function and I will go over this explicitly in a separate video now I will also bring up print in that video so you kind of fully get the intuition for what print is however this is of course the first video you're watching on scripting I am not going to ever expect you to know what any of these things are I'm just giving you basic information so that maybe if you want to research on your own a little um when I bring up stuff like like keywords that you might not understand that's kind of me hinting that like you can go research it yourself but really you don't have to worry about it because I'm going to explicitly tell you what that is later on when it becomes useful but either way just know that out of all of that esoteric gibberish the point is you can put any amount of arguments remember arguments I said were just the thing that you want to be done with the function which is print and you might ask what does that look like well let's write a string remember double quotations hello and if we run and we click on run here and it loads we will get get the text hello in the output ain't that cool let's stop let's go back to our script let's add another argument because hello is an argument let's add another argument put a comma put a space now let's put the number eight what do you think's going to happen well let's find out let's go wouldn't you know it hello eight but you might be asking me well actually I know you're asking me why is there a space between hello and eight well I'm going to explain that so first of all I want you to know why this might be useful let's say you're saying let's say you want to print out a string and a number in the same print well I could do this print five well there you go I just printed a hello and five separately and Let's do let's run this and you can see they occur one after the other so hello runs first five runs next and you might wonder why and I'll tell you why it's because hello is on the first line whereas print five is on the second line so whatever it goes top to bottom for this sort of stuff and you can also see that right here so script one script two that means the line and this is the name of the script okay sorry I had to do something for a minute I'm back but as far as I remember we were talking about script one script 2 which means okay this is the name of the script this is the line that this the thing above it was executed look script 25 line two of script printed five that's correct now let's just rename our script so click on it make sure it's blue then click the name itself and it'll open this little uh thing where you can kind of type it let's say Bob okay and if you couldn't do that just do just right click it go to rename and then it'll do the same thing so let's run this again let's run it and look what we get Bob 2 Bob Bob one and if we click on the statement itself it leads us to the line that it was printed on so if I click five it goes to the second line so that's pretty cool that's what the output that's that's a nice feature of the output so let's go back into Bob here now let's say I wanted to print this on the same line maybe I wanted to be neat or maybe I want it to present itself a certain way so let's just get rid of this cuz we want to do it on the same line and if I remember correctly I already showed you this comma which means we're going to add another argument and we're going to put five five is sorry hello the string is the first argument five is the second argument an argument is something that we are going to print out in this specific print function the comma separates each argument so each thing that we're going to print out with a space so when we run this we're going to get hello space five you're probably wondering how do I do it without a five that doesn't make any sense what if I didn't want a space there well that's fine you don't have to do that there's another way and this is what's called concatenation concatenation basically just connects two arguments together without a space and you'll see when I print this it's going to print hello and then five but there's no space so that's how you can connect two things because I mean otherwise there's not really any way you can just write five like you can't just do this that's incorrect that's incorrect syntax which is the language we're using this is not how the language works you want to include two data types well then you have to either concatenate which is two dots so let's say Hello dot dot five and concatenate like I said connects two arguments so two things that we're going to print but it doesn't put a space between them and if you're clever you might have realized there is still a way to put a space between these two how do you do it well you make a space in the string and you'll see that if I run this like this it's actually just going to make a space at the end of our string and then we print five without a space but since there's already a space there sorry I didn't click run there uh it's going to have a space hello five I have had instances where I had to connect a string with another uh data type so that is important to not so concatenating just mean you're connecting two arguments or two things that you're going to print but it doesn't put a space between them as long as you don't have a space in your string and then obviously I made the other example of just making two separate arguments with a comma the comma basically separates two arguments so two things you're going to print and I'll keep saying that over and over again okay you got to get the strill in your head an argument is just the thing that you are going to print in this specific function the print function okay and we're going to talk about functions later don't worry but just drill that in your head that is what an argument is it's just the thing that you're going to print so we're going to print hello let's say we want another argument well if you want two data types you have to separate them either with concatenation which is the dot dot or by putting a comma and always remember that concatenating does not put a space between your two data types whereas comma puts a space between your two arguments the two things you're going to print you might be wondering well these arguments how many arguments can I have you can have as many as you want I can print one two hello I could print Pizza sorry about that I could print 56 I can print as many as you want and the list goes on dot dot dot and so if I predict correctly all of these should have spaces between them and they will all be in the same line and there you go one two hello pizza 56 all on line one so now you should know kind of what an argument is it's just the thing that you want to print out with this print function I don't really know what else to call it for now because you don't know what a function is like print statement the print statement and by statement I just mean whatever is inside of this all of this stuff combined is called the statement basically the thing that you're printing I'll just call it that for now because I mean saying print function might make it a little more confusing so we'll say the print statement and statement once again just means whatever I put in here so let's say I put hello um oh my Lord okay three five Bob hello 35 Bob that is the statement whatever is in between these parentheses that is the statement we have a print statement hopefully that makes a little more sense so now you should know what an argument is it's the thing that you're trying to print you can have as many arguments as you want in a print statement so we have hello so one then we have a comma so two another comma three another comma four comma is how you know you have more than one argument well unless you put it in in another statement so let's say I have a comma in this print statement hello my name is aile well obviously that's the same argument but if you have it outside of this uh double quotations well we just have a regular comma here which indicates that we're going to the next argument so we have one comma two comma three comma four arguments we have four arguments so four things were going to print and I should clarify when you concatenate which means you connect two data types so if I say Hello dot dot five this is one argument because you still have to put a comma to separate the next thing oh don't worry about what that means okay D dude I swear I did not mean to type that like I just put three random letters into my keyboard and that just happened to be what I wrote I swear dude but either way um so concatenating does not make more than one argument this is all one argument but once you see the comma and you go to the next thing that is what indicates the next argument so either way now you know what a string is you know what a number is you know what an argument is you know what a print statement is you know what a print statement does you know what canc pation is you know what the comma does so once you've reviewed all of that information that is all I want you to know okay this bariatic function function all this crap you do not need to know that you you don't need to know any of that I just want you to get familiar with the syntax oh yeah that's another word you should learn syntax in the most simple way syntax is just the language that we're using when we code that's all it is that's all you need to write down if you're writing down notes you can write down notes if you want you don't have to but there is one last thing I want to talk about before I end this video good job if you've made it this far I'm sorry if I fried your brain uh if not good job keep following um but I hope this isn't too overwhelming I hope this is making sense uh I'm going to explain a lot more next video we're going to get into a lot of different stuff which is going to explain a lot of this stuff that I've talked about uh like once again it doesn't have to be solidified of course it doesn't it is going to take time now let me stop holding you up we're going to get to the last topic and we're going to talk about arithmetic I'm going to assume you know what arithmetic is it's basically adding subtracting multiplying and dividing so I'm only going to use those four there are other math operators that you can use in scripting but I'm not going to go over those those are more advanced in relation to what we're doing anyway way and I will cover those in another video but we're going to stick to those main four so adding subtracting multiplying division you might be asking what can I do in this print statement and how does that relate to the math well let's do 2 plus two we're adding numbers so we're going to use a number data type and you know it's a number data type because it doesn't have quotations around it and often uh I don't know if it's is going to be the case for you but number data dat types and string data types are going to be different color so you can see on mine it's green and then the orang and then the Orange is the number data type this will probably not be the case for you I don't know if it will be maybe it will be but those colors actually indicate what they are like for instance if I write 2+ 2 here it's green but here it's orange and the plus symbol is white or gray I don't know exactly what it is but that indicates we're actually adding 2 plus 2 as a string what do you think that would print out well let's let's let's click run let's click run so we have two arguments 2 + 2 and 2 plus 2 as a string so you could see that in the first argument we did 2 + 2 comma so next argument string 2 + 2 so you can see remember when we put a comma it puts a space between the first argument and the second argument so the first argument is 2 + 2 we get four isn't that interesting we can do math with our print statements but then we go to the string it literally prints out the string 2 + 2 of the text sorry so don't confuse that it's actually going to print out exactly what you write it is not going to do the math you have to do it in the syntax using the syntax which is just the language that defines the code and how everything works basically so let's stop and let's just do subtraction so we can do 2 minus 2 what do you think that's going to be I'm going to leave it to your imagination of course it's zero then let's do multiplying I think this should kind of make sense but I'm going to just going to do it anyway the multiplying is the star uh which is shift 8 on your your keyboard it should be we get 2 * 2 which is four and then we have two divided by two which is slash so two slash two of course it's going to be one that is the syntax or the language to describe to do the math so slash is division star is multiplication Dash is minus and shift plus is uh or shift equals uh will give you plus which is the symbol for addition so that's how you do all that stuff and obviously you can do as many terms as you want 2 plus 2 plus two plus 2 plus two times two and you'll get it'll do all the math in the correct order so should it should give you um 2 * 2 4 + 2 which is 6 8 10 12 14 so it should give you 14 if it does pem das pmass I don't know whatever um whatever it's defined as for you uh and obviously yeah it gives you 14 because I did it in the P Mass P pem Das I don't know there's so many versions of it but yeah it's going to do that so that is the last thing I'm going to go over um arithmetic so by now you should know kind of what a print statement is what you can do with a print statement you should know what an argument is and what separates arguments you should know that you should be able to have as many arguments as you want you should know what a string is kind of vaguely I hope you understand what a string is it's basically just text you should know what a number is which is just a number you should kind of vaguely know what concatenation is which means you can connect two data types oh and you should have a basic understanding of how to read the output most of the stuff is junk uh maybe I've explained that I don't know but the only thing that matters is what comes from your script you have this you have uh the script name and then the line that the code was executed on and then you have the output um or sorry the print statement and that is whatever is inside here you should know that you should always put your server scripts in the server script service because it is the most secure way of creating your scripts your server scripts will which I will get into in a later video just know you should put it in your service script service these scripts right here it should look like that if it doesn't look like that or have that icon then it's not a server script this is a server script you don't need to know what that is but just remember if it has its icon you should always be putting it in the server script service so that's all I really expect from you in this video if you need to do a little practice like you want to get familiar with print statements and see what kind of wacky stuff you can do with it if you want to ask me questions like if you done anything with print statements and you're kind of confused about something feel free to comment I will try to answer everything I can uh but that about wraps up this tutorial um I'm really excited to Kickstart this journey we're gonna hopefully be pumping out a lot more scripting tutorials gonna try to upload consistently I hope I can I hope I did a good job on this I hope you guys enjoyed this I hope it helped uh please let me know if something I said did not make sense there's something that I said that I kind of just assumed you knew because I don't want to assume that you know anything I try to let you know if there is stuff that you should know and like if I say something and you don't get it I will try to let you know like if it's actually something you need to know or not uh but if I really did miss something please let me know I appreciate any feedback that I can get so I can help improve this is my first video so but anyways if you watch to the end I appreciate it a lot if you want to subscribe and follow my tutorials if you want to like the video as well I would really appreciate that but thank you guys so much for watching I hope this helped you out and I'll catch you all in the next one until then adios