|
|
Line 1: |
Line 1: |
| __NOTOC__
| | #redirect [[In-Depth Scripting Guide#"while true do" loops]] |
| {{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/>
| |
| 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
| |
| </pre>
| |
| | |
| Here's another example of 'loops' in the form of a killing script:<br>
| |
| | |
| <pre/>
| |
| 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
| |
| </pre>
| |
| | |
| Short; but effective in Script Builders.
| |
| | |
| [[Category:Scripting Tutorials]]
| |