6kany76
|
  |
| Joined: 19 Feb 2015 |
| Total Posts: 749 |
|
|
| 16 Apr 2016 12:02 PM |
A script is a series of instructions for a program to follow to create custom behavior. In order to give these instructions, you must provide the instruction in words the program can understand. ROBLOX uses a language called Lua to communicate these instructions. In this set of tutorials, we will go over the basic instructions you can use in ROBLOX Studio to create games.The Command Bar shows up at the bottom of Studio by default, and is a place where we can write instructions for the game. The Output window will show any kind of text responses from the game.The first instruction, or function, we will cover is called print, which makes text appear in the Output window. In the Command Bar, type: print("Hello world!") After you are done typing, hit enter. The Output panel will show both the instruction and the message we wanted to print:
> print("Hello world!") Hello world! print will output whatever is in between the parenthesis () that follow it. In this case, we printed out the sentence: Hello world!. When you want to print out sentences, which in Lua are called strings, you have to surround the sentence with quotations.
We can print other things, like numbers:
> print(7) 7 Notice how we did not put 7 inside of quotation marks "". If we are printing out a number and not a string, we do not need to include the "".We can also print out the result of mathematical operations. For example, if we want to print the result of adding two numbers, all we have to do is:
> print(7 + 3) 10 We print all kinds of operations:
> print(10 + 5) 15 > print(10 - 5) 5 > print(10 * 5) 50 > print(10 / 5) 2
In scripting we often want to store information to be used later. We can do this by using variables. You can think of a variable as a box you put information in. To create a variable, all we need to do is give it a name and assign a value to it. For example:
> myFavoriteNumber = 7 The above line of code stores the number 7 into a variable called myFavoriteNumber. Notice how nothing is added in the output after we enter the above line. That is because the print function was not used. If we want to see what is stored inside of myFavoriteNumber we can put it inside a print function like this:
> print(myFavoriteNumber) 7 Like print, variables also work with mathematical operations and can store the results for future use:
> theSum = 5 + 6 > print(theSum) 11 We can also store strings inside of variables. Just like when we printed strings before, the string has to be surrounded by quotation marks "".
> myFavoriteAnimal = "Dog" > print(myFavoriteAnimal) Dog We can give variables almost any name we want. There are a few rules one has to follow in Lua though when naming variables though:
-Variable names cannot have spaces in them. -Variable names cannot start with numbers. -Variable names cannot have any special character except for underscore: _. Some words in Lua are reserved for special uses. Variable names cannot be the same as these special words. A few examples are for, and, end, if, and while. Variable names should not be the same as functions. For example, you technically can use the word print as a variable name, but it would ruin your program as that would overwrite the actual print function. In the next tutorial we will cover creating parts and changing properties through code. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2016 12:06 PM |
lol
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2016 12:06 PM |
| Shouldn't you've explained one of the most important concepts with variables: how data is returned from certain math operations and functions? |
|
|
| Report Abuse |
|
|
6kany76
|
  |
| Joined: 19 Feb 2015 |
| Total Posts: 749 |
|
|
| 16 Apr 2016 12:10 PM |
| Hey this is why people avoid the forums. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2016 12:23 PM |
Stop rejecting criticism. You copied another tutorial straight from the wiki.
|
|
|
| Report Abuse |
|
|
6kany76
|
  |
| Joined: 19 Feb 2015 |
| Total Posts: 749 |
|
|
| 16 Apr 2016 12:37 PM |
| this is for people who never seen this on the wiki stop trying to get me banned. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2016 12:41 PM |
This needs to stop.
[Insert RecurringNightmare Youtube sponsor]
|
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
| |
|
|
| 16 Apr 2016 12:44 PM |
@woolhat
Same. I knew I couldn't be the only person already tired of this.
|
|
|
| Report Abuse |
|
|
6kany76
|
  |
| Joined: 19 Feb 2015 |
| Total Posts: 749 |
|
| |
|