Loops: Difference between revisions
>ThePeaceWiki Scripting Tutorial |
>Outofspace This should be merged into another article. |
||
Line 2: | Line 2: | ||
{{CatUp|User:ThePeace}} | {{CatUp|User:ThePeace}} | ||
== | 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. | |||
<pre/> | <pre/> | ||
while true do --Starts the loop off | while true do --Starts the loop off | ||
m = Instance.new ("Message") -- | m = Instance.new ("Message") --Creates a message. Reffrences it as 'm' | ||
m.Parent = game.Workspace -- | m.Parent = game.Workspace --Sets the Parent. | ||
m.Text = " | m.Text = "Warning!" -- Makes the message say 'Warning!' | ||
wait( | 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> | ||
Here's another example of 'loops' in the form of a killing script:<br> | |||
<pre/> | <pre/> | ||
while true do | while true do | ||
game.Workspace. | a = game.Workspace.PlayerName --Put a person's name here. | ||
wait( | 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. | ||
[[Category:Scripting Tutorials]] | |||
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.