|
| 07 Jan 2014 12:29 AM |
| ^ How do I loop in a script? |
|
|
| Report Abuse |
|
|
| 07 Jan 2014 12:30 AM |
while true do --stuff wait() --number end |
|
|
| Report Abuse |
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 07 Jan 2014 01:11 AM |
| http://wiki.roblox.com/index.php/Generic_for |
|
|
| Report Abuse |
|
|
| 07 Jan 2014 01:18 AM |
condition wait end
while true do print("Hello!") wait(1) end
If you do not have the wait(1) in the script then your game will crash in that instance because the script will run math.huge times in under a second.
You could also do:
for i=1, #100 do print("Hello!") wait(1) end
This will print "Hello!" every second for 100 seconds. This is because #100 is in the first line. If you used "for i=1, #50 do" for the first line, it would do it for 50 seconds. If you did wait(0.5) times it would do it 100 times in 50 seconds.
You can also use anonymous functions in loops, for instance;
game.Players.PlayerAdded:connect(function(player) if player.Name = "ScriptingBoa" then print("Script has joined the game! Hooray!") end end)
"end)" is used because "(function" started a parathesis, and the "end)" closes that.
Have a nice day. :) |
|
|
| Report Abuse |
|