Loops

From Legacy Roblox Wiki
Revision as of 03:07, 28 September 2008 by >Outofspace (This should be merged into another article.)
Jump to navigationJump to search

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.