User:JulienDethurens/Guide/Introduction
The introduction will introduce you to scripting, by telling you the very basics. You will not really learn any syntax or anything like that in this section, you will just learn some important informations about scripting.
Scripting
So you want to learn scripting. After all, that's the reason you're here, right? But, first of all, what is scripting? You probably already know it, but I'm still going to explain it.
Scripting means the same thing as programming. It is used to tell your computer what you want to do. In this case, since we're on ROBLOX, we use ROBLOX Lua, a modified version of Lua, to interact with the ROBLOX API and create awesome places for other users to play.
When you create your place, you have a vast choice of objects to use to do many things. All of these objects can do different things, and they can all be manipulated by scripting, which makes it possible to do even more things. And this is precisely what you're going to learn: how to use scripting to make your places better.
ROBLOX Lua, like every programming language, has a syntax, and libraries. In fact, pretty much everything there is in a language is its syntax and its libraries. By libraries, in this case, I mean built-in functions and everything. C++ has a syntax, and offers built-in functions and libraries. C has a syntax and offers built-in functions and libraries. Java has a syntax, and offers built-in functions and libraries. And ROBLOX Lua, too, has a syntax and offers built-in function and libraries. However, unlike C++, C and Java, ROBLOX Lua is an embedded programming language, which means it is embedded in an application. This application is ROBLOX itself.
But, what is a programming language, you might ask? Well, a programming language is a language, just like English. It's just that it is used to talk with a computer, not to talk with humans. And, you see, computers don't have a brain that can think like ours, so you're going to have problems communicating with them. They won't understand what you tell them unless you say it in a specific way.
Scripts
To script, you will need to use... scripts! You probably already know how to insert a script, but, if you don't, don't worry, I'll explain it here.
To create a script, first, you must open Roblox Studio. To do this, simplest way is to go in the start menu, click 'All programs', choose the Roblox folder and choose 'Roblox Studio'. A window should appear with a browser and everything. From there, just press CTRL+N, or go in the File menu and choose 'New'. It will open a place. From there, you can do lots of things. If you've never used the studio before, you'll find all these buttons everywhere confusing. If you're a builder, you'll find it a lot less confusing. But, don't worry, in both cases, I'll tell you what to do, so you don't get lost.
Inserting a script is simple. Just go in the Insert menu and choose 'Object...'. A window with a list of objects will appear. One of the object is called 'Script'. Select it and click 'OK'.
The script will be put in the Workspace, in the explorer. If you don't see the explorer, go in View and choose 'Explorer'.
I know I'm explaining everything, and you might already be used to the studio, but I'm still going to continue explaining everything for a while, because not everyone has used the studio before. Don't skip a section, even if you think you already know everything it contains.
You have a script. That's nice, and all, but, what to do with this script? Well, to edit a script, you first need to open it, which can be done by double clicking it. So double click the script in the explorer.
Then, the script editor will appear. It lets you edit your scripts. Personally, I use an external editor, because I don't like the built-in script editor, but since you're beginning, you should just use the built-in script editor. I'll explain more about external script editors and other subjects at the end of the book, in the miscellaneous section. You can read that section at any moment, by the way. You don't need to wait until the end to read it. It contains informations that could be useful and that do not necessarily require to have read all the book to understand.
Hello World
The script editor should contain one line, right now:
print 'Hello world!'
You might wonder what that does. Actually, it shows 'Hello world!' in the output when you run the game. You can run the game by going back to the studio view (choose 'Place1' or something similar in the tabs list) or by closing the script editor (click the x button in the top-right corner). Once back in the studio view, just click the green arrow (should be on one of your toolbar) and all scripts will run. However, to see the result of the default script, you first need to open the output. Just go in View > Output to open it, and then click the pause button (next to the run button) and click the run button again, to re-run the game. The message 'Hello world!' should appear in your output.
To go in a little more detail, that code runs the print function with 'Hello world!' as argument. However, we'll talk about all of that later.