| |
|
zakary99
|
  |
| Joined: 19 Jan 2010 |
| Total Posts: 1095 |
|
|
| 15 Jun 2013 05:25 PM |
local broken = false while true do if broken == false then print("Lol") end wait() end
function break() broken = true end break() |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Jun 2013 08:29 PM |
breaknow = false
function Func() while true do print('lol') wait() if breaknow then break end end end
function DoBreak() breaknow = true end |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Jun 2013 08:34 PM |
| You would have to call stoploop, which can't be called as long as the loop is actually running, use a coroutine |
|
|
| Report Abuse |
|
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Jun 2013 08:37 PM |
Think of it as a "script within a script" or a "thread"
If you do:
while true do --code end
--code2
code2 will not run unless the loop is stopped, however if you put the loop in a coroutine, code2 will run at the same time.
coroutine.resume(coroutine.create(function() while true do --code end))
--code2 |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Jun 2013 08:43 PM |
No, remove the first part and second part "while true do camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, -5) angle = angle + math.rad(1) end
function stoploop() breaknow = true end"
and keep the bottom part |
|
|
| Report Abuse |
|
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 15 Jun 2013 08:54 PM |
Add a: breaknow = false Over the corooutine
and add another parenthesis after the "end)" so it's "end))"
And anytime you want to stop the loop, run stoploop() also, add a wait in the loop so you don't crash |
|
|
| Report Abuse |
|
|
| |
|