User:Tomtomn00/Scripting Tutorial: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>SoulStealer9875
False examples, do you even know how to script!?
>Tomtomn00
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{User:Tomtomn00/Sandbox/NoEditTemplate}}
<!-- 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=4>'''Some of you may be looking for a more basic tutorial than the advanced one, so here is mine!''' </font>
__TOC__
__TOC__


Line 70: Line 69:
</pre>
</pre>


[[Warning.png]] - Remember to use the open and close brackets!
[[Image:Warning.png]] - Remember to use the open and close brackets!


==Defining Models==
==Defining Models==
Line 83: Line 82:
  a=game.Workspace.Part
  a=game.Workspace.Part


'''or'''
'''or if in a group;'''


  b=game.Workspace.Model.Part
  b=game.Workspace.Model.Part

Latest revision as of 18:32, 11 January 2012

Do not edit!
The creator of this subpage does not want it to be edited without permission.

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(second)

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

GetChildren

This method can be used for returning a table that contains all the descendants of the given ascendant. To make this easier, use variables.

i=game.Workspace.Model:GetChildren()

or

m=game.Lighting:GetChildren()

- Remember to use the open and close brackets!

Defining Models

This explains how to define models. You need to explain where the model is to the script. You use variables and can use :GetChildren with this.

t=game.Workspace.Model

Defining Parts

This explains how to define parts. You need to explain where the part is to the script. You use variables and can use the GetChildren method.

a=game.Workspace.Part

or if in a group;

b=game.Workspace.Model.Part