User:Tomtomn00/Scripting Tutorial: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Tomtomn00
 
>Tomtomn00
Line 1: Line 1:
<!-- Note: I do have permission to write scripting articles from Mr Doom Bringer. -->
<!-- Note: I do have permission to write scripting articles from Mr Doom Bringer. -->
<font size=5>'''Some of you may be looking for a more basic tutorial than the advanced one, so here is mine!''' </font>
<font size=4>'''Some of you may be looking for a more basic tutorial than the advanced one, so here is mine!''' </font>


__TOC__
__TOC__

Revision as of 16:36, 19 August 2011

Some of you may be looking for a more basic tutorial than the advanced one, so here is mine!

Output

The output is used to see if scripts are running and to see what is being printed from them. You can see it by opening ROBLOX Studio -> View -> Output.

Print Function

The print function can only be used to print what is going on in output.

You would use this code for printing:

 print() 

But, before trying you would need to say that it is a string so it will print what is in the string. Example:

 print("Hello World") 

The output for that would be Hello World. However if you do not want to use "", you can look in the variables section below.

Variables

Variables are most commonly used with the print() function.

A variable is something to show what something is. When using a number as a variable you would just use something like:

 roblox=1 

- that would mean that roblox is the same as 1. So you can use

 print(roblox) 

and it would print in the output 1. However, if you want to make the variable a string you would use something like:

 roblox="car" 

- that would mean that roblox is the same as a car. You could print this now:

 print(roblox) 

and the output would say car.

Wait Function

The wait function can be used to say how long the script waits to do the next command. Whatever goes in the brackets of wait() is in seconds. This is a demonstration with the wait function.

print("I like to play ROBLOX")
wait(1)
print("Hello World")

That would print I like to play ROBLOX, wait 1 second, then print Hello World.

Math

Lets say that you want to add with ROBLOX Lua. You will need to use math (above,) variables (2 above) and the print function (3 above.) Say you want to print 3+4, wait 10 then print that with +1 onto it. You would do as follows.

first=3+4
print(first)
wait(10)
second=first+1
print(first)

That would make the output print 7, then it will wait 10 seconds, then print 8 in the output.