The purpose of this guide
This guide is for those who have absolutely no understanding of what scripting is and aren't able to write a single line of code. This accounts for more than 99% of Roblox players. This guide won't teach you how to make the awesome stuff that has probably drawn your attention to this subject, but this will teach you what scripting is so you are at least capable to study all those tutorials and scripts made by others.
Note that this guide is focused on teaching the reader the main principles of scripting in Roblox and a way to get started with it, not to confuse the reader with complicated terms and being precise or exact. However, the learning curve in this article is still quite high, so if you have trouble understanding some parts, slow down and reread the article a few times.
Scripting is what actually makes blocks in Roblox do things, and without it, your character's limbs wouldn't move when you are walking and a rifle would just be a bunch of parts being held by your character, if it doesn't just fall apart when equipped. In short: scripting is what makes Roblox come to life and make places fun. It is very understandable that people want to learn how to do it and make cool places. Contrary to popular belief, scripting isn't hard at all, it's just something totally new that you need to understand first. It's very simple to make scripting easy. Just read these passages.
Roblox Studio Basics
We use a program called "Roblox Studio." If you play any Roblox game, the application will automatically be added to your device. Open the application and create a new place.
Look at the top of your screen. It should look like this, assuming dark mode is turned off. It may look different due to updates, but the image below shows what it would look like as of June 25, 2021.
Let me explain the basics:
There are five tabs at the top: Home, Model, Test, View and Plugins. For the purpose of keeping this tutorial simple, we will focus on the Home and View tabs.
- The Home tab contains the most basic functions needed, such as creating parts and changing its color.
- The Model tab is reserved for functions needed for creating more complex models, like unions and negates. However, we will not focus too much on this tab.
- The Test tab contains functions used to test your game to look for bugs.
- The View tab allows you to open certain windows in the game.
- The Plugins tab allows you to use Plugins, which are downloadable tools to help with building and scripting.
For this tutorial, we will focus on the Home tab.
You should have the following windows in your game. If not, go to the View Tab on the top, and open the following windows:
- Explorer. This is a manager for all the objects inside your game.
- Properties. This is a window that manages and lets you manipulate the properties of an object. I will explain them in the beginner series.
You can reorganize the Studio however you like, but I like to keep the Explorer tab on the right of the screen, and the Properties and Output on the left.
The Home Tab
Let's focus on the functions of the Home Tab.
There are four functions under the Tools section: Select, Move, Scale and Rotate.
- Select and Move are used to move the parts around the studio.
- Scale is used to resize parts.
- Rotate is used to rotate the part, as the name suggests.
The Terrain Editor is used to add terrain (dirt, snow, grass, etc.) to your world. It is far easier to add terrain using the Terrain Editor than to build the terrain out of blocks.
There are 3 functions under the Insert section: Toolbox, Part, and UI.
- The Toolbox opens a window that allows you to access free models, which are basically models created by other players that you are free to insert into your game. However, avoid using this feature excessively.
- The Part function adds a block into the game. This is more commonly known as a Part, but they are officially called Base Parts. If you click on the ▼, you will see that there are 4 shapes of a base part: Block, Sphere, Wedge and Cylinder. Clicking on any of these options will spawn a base part into the :
- The Block shape is a rectangular prism or cube.
- The Sphere shape is a ball.
- The Wedge shape is a triangular prism.
- The Cylinder shape is, well, a cylinder!
- The UI function adds a GUI, but let's not get too far into it in this tutorial.
Under the Edit section, we will focus on Material and Color.
Material affects the texture of a base part. By default, the material is Smooth Plastic. To change the material, select the part in the viewport. Then, click on the ▼ under Material, and select any material in the dropdown menu.
Color is self-explanatory; it affects the part's color. By default, the color is Medium stone grey. Clicking on the ▼ gives you this palette:
Click on any color to change the color.
There are just two functions under Test: Play and Stop. Play will allow you to play the game you created as if you were in a live server. Stop will return you to the viewport.
(If you cannot figure out what each tool does, a detailed tutorial for Roblox Studio can be found here.)
Within the tutorial after this one, we will learn to create a script that activates once the part it is in is touched.
Writing a script
To create a script, hover over any tab in the Explorer window. A plus sign should appear. Click it, and find "Script" in the popup that appears. Click it, and you should have a script ready to go, with "print("Hello world!")". We will explain what it does in the Beginner Tutorial. For now, remove it. Now, your Explorer should look like this:
We refer to this as a hierarchy, which means that one object is ranked "higher" than another. This is indicated by the indents in the explorer window. In the above case, the Workspace is the highest, because it has the least indent.
Because the Part is directly below the Workspace in the hierarchy, we say it is the Workspace's child, and the Workspace is the Part's parent. To be clear,
In the above case, the top brick is the parent of the bottom brick, and the bottom part is the child of the top part.
A path in Roblox scripting is like directions the script uses to access the script. You would start with game, then work your way downwards in the hierarchy, separated by dots. So, if I were to access the Part in the above example,
Now, we did that, but now what? This script would access the part, but would do nothing to it. So, we set a property.
game.Workspace.Script.Name = "Script" --Change the name to whatever you want.
This would rename the script.
To run your script, click the green 'Play' button at the top of your screen. If the script's name changed to whatever you entered it to be, then congratulations! Your script works!