What is a script?
Lesson 1
Last updated
Was this helpful?
Lesson 1
Last updated
Was this helpful?
For those who are new to Roblox development, we’ll first have to open Roblox Studio, which is the game engine used by Roblox. I am assuming that you already know the very basics of Roblox Studio. So after you open Roblox Studio, create a new Baseplate place and open it.
Now you are on a new empty baseplate. Before we start scripting, there are a few windows we need to open:
The Explorer Window: This shows a list of all the instances in our game.
The Properties Window: This allows us to change the properties of the selected instance.
The Output: This shows us the output of our scripts, script warnings, and errors.
Command Bar: This allows us to run different LUA commands.
To open them, go to the “View” tab and select them one by one.
Now, your layout should look similar to this.
Keep in mind that you can change your layout by dragging and dropping windows and resizing them. I recommend making sure you are comfortable with your layout and that it’s not very messy.
Now that we've got everything ready, we can create our first script! So first of all, let’s talk about what a script is. A script is a set of instructions to perform specific tasks in a certain way. For example, let’s say you want a player to get a speed boost when touching a specific part. The instructions would look something like this:
The part gets touched
Find out who touched the part.
Give more speed to the player who touched the part.
Now that we know what a script is, I will let you get used to some terms we are going to use during this course:
Server: The server is the most important part of a Roblox game. It is the central place of any online game.
Client: A client is a program that allows you to connect to the server.
An easier explanation of the client-server model would be the following:
When you join a Roblox game, your device becomes a client. Also, all the other players connected to the same game are clients. All the clients are connected to the server, so they can see and interact with each other.
Don’t worry if you don't fully understand the client and the server, you will understand later on!
What is important for you to know is what the two main types of scripts are on Roblox:
Local Script: It will only run on a player’s client.
Server Script (called just Script): It will run on the server.
For example, if we’d want the shop to open when clicking a button, we would have to use a Local Script, since it will only open on the client of the player who clicked on the button. But, if we want to make a building system so the players can build things, then we’d use a Server Script since we want all the players to see what you build.
The location of your script is also very important since it will determine what the script can change, but for now, don’t worry about it!
Now we are ready to create our first script. To do so, open Roblox Studio and go to your Baseplate. For now, we are just going to put the script inside Workspace so it can make changes to the things inside of it. To create a script, hover your mouse over the “Workspace” drop-down inside the Explorer and click on the plus icon. After that, search for “Script” and click on it.
If you followed my instructions and they worked then congratulations! You just created your first script. This is what you probably see now:
To make your text bigger or smaller, hold down CTRL (or Command on Mac) and use your scroll wheel to zoom in or out.
Now, you may be asking yourself what the following line means:
Whenever you create a new script, you will see this first instruction as the default. The print function is one of the most basic functions on Roblox. All it does is that it prints something to the output whenever the script runs. In our case, it will print Hello World! (always needs " "). To see how that works, click on the "Play" button and check the output!
What we can now do is change the message that gets printed. You can change it to anything just by editing the text inside the quotation marks (“ “). For example, I changed mine to:
Can you guess what my output will be?
Remember, if you did anything wrong (for example, you forgot the quotation marks) then the output will display an error. Errors are very useful when we do something wrong in our scripts since they tell us the mistake we made!