Loops: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>ThePeaceWiki
Scripting Tutorial
>Outofspace
This should be merged into another article.
Line 2: Line 2:
{{CatUp|User:ThePeace}}
{{CatUp|User:ThePeace}}


== Ummm ==
This is a basic scripting tutorial.
Ya. I'm ThePeace. I made this page because... I dunno. Oh, Scripting Tutorials.
 
== Scripting ==
This will teach you some of the basics of [[scripting]]. Starting with something called '[[while true do]]' and 'end', very important terms in Lua scripting. They both create 'loops' which repeat after an ammount of time. If no ammount of time is set, Roblox will crash. To start it off, I'll show you a simple "Fog" [[script]] and then break it down for you.


== Tutorials:Scripting ==
Hello. I'm going to teach you some of the basics of scripting. Starting with something called while true do and end, very important properties in scripting with Lua. To start it off, I'll show you a simple "Fog" script and then break it down for you.
<pre/>
<pre/>
while true do --Starts the loop off
while true do --Starts the loop off
m = Instance.new ("Message") --Introduces a new message for the server to show
m = Instance.new ("Message") --Creates a message. Reffrences it as 'm'
m.Parent = game.Workspace --Makes it exist
m.Parent = game.Workspace --Sets the Parent.
m.Text = "FOG!!!!!!!!" -- Makes the message say FOG!!!!!
m.Text = "Warning!" -- Makes the message say 'Warning!'
wait(0.1) --It waits that long
wait(2) --Sets how long until the text is changed.
m.Text = "Fog Alert!" --Sets the message to 'Fog Alert!'
wait(2) --Makes the script wait this long before repeating.
end --Finishes the loop
end --Finishes the loop
</pre>
</pre>


While true do and end are loop starters and enders. Loops are things that happen over and over. Very useful at times. Here's another example of while true do and end. In the form of a killing script.
Here's another example of 'loops' in the form of a killing script:<br>
 
<pre/>
<pre/>
while true do
while true do
game.Workspace.Player'sName:BreakJoints()
a = game.Workspace.PlayerName --Put a person's name here.
wait(0.01)
a:BreakJoints() --Breaks the person's joints.
wait(10)--Waits 2 seconds before repeating.
end
end
</pre>
</pre>
Line 26: Line 30:
Short; but effective in Script Builders.
Short; but effective in Script Builders.


== Updates: ==
[[Category:Scripting Tutorials]]
I might update soon when I have the time.

Revision as of 03:07, 28 September 2008

This is a basic scripting tutorial.

Scripting

This will teach you some of the basics of scripting. Starting with something called 'while true do' and 'end', very important terms in Lua scripting. They both create 'loops' which repeat after an ammount of time. If no ammount of time is set, Roblox will crash. To start it off, I'll show you a simple "Fog" script and then break it down for you.


while true do --Starts the loop off m = Instance.new ("Message") --Creates a message. Reffrences it as 'm' m.Parent = game.Workspace --Sets the Parent. m.Text = "Warning!" -- Makes the message say 'Warning!' wait(2) --Sets how long until the text is changed. m.Text = "Fog Alert!" --Sets the message to 'Fog Alert!' wait(2) --Makes the script wait this long before repeating. end --Finishes the loop

Here's another example of 'loops' in the form of a killing script:


while true do a = game.Workspace.PlayerName --Put a person's name here. a:BreakJoints() --Breaks the person's joints. wait(10)--Waits 2 seconds before repeating. end

Short; but effective in Script Builders.