welcome back to my Roblox beginner scripting tutorial series my name is balev and in this episode we'll be discussing about data types so again this is the next coding fundamental um concept that we need to know for scripting to become a better scriptor now what we're going to do for this episode is actually create a new script so that we can organize our scripts uh when we go further down the line with this tutorial guide because if we were to go back to the scripts that we've been making throughout this tutorial um it can get
very lengthy very fast if we used the same script throughout the entire tutorial guide so what I'm actually going to do is go back to our game and I'm going to go to the right side of the workspace and I'm going to go down to this property here that says enabled so I'm actually going to uncheck this property so that when the game runs so if I hit play then whatever we put inside of the script isn't going to run in the output because it's now disabled so the script isn't going to fire when we
join into the game and so that is a property that um you might find to be useful if you were to have scripts that you don't want to execute when the game runs inside of Studio or just in the game in general so now what I'm going to do is hit stop and now we want to create a new script for this episode uh and to make this more organized what I'm going to do is actually rename the script on the right side here so I'm going to right click on the script and I'm going
to hit this button that says rename and it's going to highlight the name right here so what we can do is basically just delete this and we can insert a new name here so I'm going to rename this to printing data types just like this and I'm going to hit enter uh it doesn't matter what you call it but I'm just going to call it printing data types and so now we can create a new script so I'm going to click on the plus sign next to workspace and I'm going to search up script just
like this and I'm going to insert a regular script just like this so I'm also going to click on the script right click it and I'm going to rename this one to uh the name of this episode which is going to be variables so now that we have that taken care of I'm just going to zoom in just a little bit so you can see it better and I'm also going to x out of our previous script inside of the script um editor like this and now we should be at the normal game and also
uh have the variables tab right up here so now that we have this taken care of let me introduce you what a variable is so a variable is basically a reference to another value now that's the simplest explanation I can give so when we have a name that references a value then we can use that name that we created that basically acts as the value that we're referencing um with the name that we created now it may seem kind of confusing to you at first but I want to write this inside of our script so
that I can um help you understand this concept better so what I'm going to do is Select this print statement and I'm going to delete it since we don't need it um now now what I want you to do is copy exactly what I type because it may be confusing to you at first so what I want you to do in all lowercase is Type in local and then what we're going to put here is a random variable name and it doesn't matter what we call this variable name so I'm just going to say my
variable like this and I'm going to put in an equal sign and I'm going to set this equal to a random uh data type value that we worked with in the last episode so I'm just going to say that this is 100 now looking at this you might be confused like what what does this all mean well to basically understand what is happening here uh we don't need to worry about what this local variable is right now I'm going to explain this in a future episode but basically what we have going on here is three
components that make up this variable so what's going on over here is this is a name that I came up with and this variable name can be whatever name we want the variable to be as long as we can reference it later inside of the script then it doesn't matter what we call this and then we have an equal sign here that basically says that we've now created a new variable that is set equal to whatever value is on the right side here which is going to be 100 so what's interesting about this is if
we drop a line down here and we make a print statement so we uh write down print and then have the open parentheses and we put down our new variable name that we created so we say my variable like this then you might expect in the output to print my variable or something similar to that but no you might actually be surprised if we go into the game hit test and hit play then what we should see in the output is actually the number 100 so if I click on this and refer back to our
script that we created it's printing out my variable but why did it print 100 it printed 100 because my variable is simply a reference to the number 100 as we specified here when we created this variable and so this is what I'm talking about when we're having a variable refer to a different data type value like this and this is really powerful to know um and it's going to be one of the most important Concepts to understand uh when we do create variables that reference other values now why do we need to know this well
if we were to hit stop so that we're out of play test mode and if I were to go back into the script I want you to imagine that we have a scenario that if I were to make a print statement like this and then print five drop a line down here and if I were to print five again just like this and drop a line and if I were to print five once again just like this then it's then it's going to be kind of repetitive and what if we wanted to change uh all
of these values then we would have to go back and change the value for each single one of these numbers but instead what if we had an easier way to do this and that would simply just be replacing this data type with a variable that is referencing a value so all we need to do is change this value and it's going to change everything else that is going to be inside of this print statement that uses the variable that we just created so if I were to basically copy this code right here so if I
were to select this and then right click hit copy and then I were to and if I were to drop a line down here and I were to right click on this and then hit paste then it's going to paste the same line that we just had that we copied and I'm going to do the same thing down here by hitting enter and then hitting paste just like this so I'm also going to delete these lines right here so that it's not going to get in the way of our script so when we have our
variable be like this we go into the game hit play then what we should see in the output is 100 being printed three different times because it's using the same variable that's referencing this data type of 100 if we hit stop and we go back into our script and then change this one value this one value to let's say 50 then we go back into the game and hit play then what we should see in the output is 50 being printed every single time we only had to change this one value uh to affect all
three of these print statements rather than having to change each individual print statement to change that one value that's a very basic way of how I can explain how variables work in C studio and this this is going to be very important for us to understand later down the line now there's a certain naming convention that I would like you to use and that's basically how we write these variables so usually what I do is what's called camel case and so I would basically have the first letter of the first word be in lowercase and
then have the first letter of every other word be in uppercase um while the rest of it is just in lowercase so if I were to extend this even further I could say my variable is 50 just like this this is how we would create the variable now as you can see down here um these print statements are throwing an errors saying unknown Global my variable and that's because we no longer have a variable that we created called my variable is 50 so what we need to do is update these variables to say my variable
is 50 and as you can see Roblox is recommending us to use this variable right here so if we want to complete this rather than type the whole thing out we can just type in tab and Roblox is going to add this in for us and we can do the same thing here as well so if we select this and say is 50 then we can just hit Tab and Roblox is going to uh correct it for us so is 50 and then just like that we have our variable taken care of so if we
hit play then we can still see that the output is printing the value 50 after referencing our variable my variable is 50 so that's the basics of using variables inside of your scripts what I want you to do for today's learning objective is to create more variables and set them equal to different data types so it doesn't have to just be numbers it can also be booleans and and it can also be strings so I want you to have these references down and be able to print them inside of the output right here and be
able to make print statements to print them effectively so we can show them inside of the output so I want you to try and do that for this learning objective and once you do I want you to go down to the comment section and show what you did for this challenge since I do look at all my comments um for my videos so it would be very nice to see what you doing for this episode as we go through this tutorial guide so that's pretty much going to be it for this episode I hope you
enjoyed it and I will see you in the next episode take care