User:Tomtomn00/Scripting Tutorial

From Legacy Roblox Wiki
Revision as of 10:45, 25 August 2011 by >Tomtomn00 (→‎Comparative)
Jump to navigationJump to search

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.

Comparative

Comparative operators are operators that compare two parameters and return a boolean. There are several operators.

== ~= > < >= <=
Equal to Not equal to Greater than Less than Greater than or equal to Less than or equal to