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 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.
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.
Alright, to start writing a script you will need to work with 'Roblox Studio'. This is a program made for editing places with more advanced tools and in a 'non-running environment', which basically means that scripts aren't running and gravity and motors do nothing while you're editing. If you have Roblox installed on your computer you should have this program - you can normally start it from Start Menu > Roblox > Roblox Studio. Now you will see a window with thumbnail of your places, now either click on an existing place or "New > Baseplate". You will now see a large grey plate/house and bars you most likely don't understand. Let me explain the basics:
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.
- Output. This is a window primarily used for debugging.
On top of the screen:
Toolbar: Icons with all sorts of tools you can use to change your place (moving/resizing parts, etc). Fiddle around with these tools and see what you can do with them. Once you're familiar with what each tool does, insert a part/brick and resize it to whatever you want using the scale tool in the toolbar.
(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.
A path in Roblox scripting is (usually) separated by dots, so the previous example would look like this in valid scripting.
But the object is nothing, so let's say we want to access the name of a script that is in the workspace, which is in turn inside the game.
game.Workspace.Script.Name = "Script"-- This is the name for what ever you name 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!