|
| 24 Oct 2015 07:25 PM |
I need it for a regen thingy and I can't put it into the while loop because it will contain more stuff in it in the future.
local recharge = coroutine.wrap(function() repeat Hud.Ki.Value = Hud.Ki.Value + 3 wait(1) until Hud.Ki.Value >= 500 or rechargedebounce == false Hud.Ki.Value = 500 rechargedebounce = false end)
while wait() do if Hud.Ki.Value < 500 and rechargedebounce == false then rechargedebounce = true recharge() end end
The noobs shall be eradicated. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Oct 2015 07:29 PM |
| You don't, instead wrap it all in a while loop and call coroutine.yield when you want to resume it later. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 07:36 PM |
I don't get it, could you please show me an example?
The noobs shall be eradicated. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 07:48 PM |
So I did this, but when the coroutine is called again it just says "attempt to call a nil value" in the console
local recharge = coroutine.create(function() while wait(1) do if Hud.Ki.Value < 500 then Hud.Ki.Value = Hud.Ki.Value + 3 elseif Hud.Ki.Value >= 500 then Hud.Ki.Value = 500 rechargedebounce = false end coroutine.yield(recharge) end end)
while wait() do if Hud.Ki.Value < 500 and rechargedebounce == false then rechargedebounce = true coroutine.resume(recharge) end end
The noobs shall be eradicated. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 07:54 PM |
omg please
The noobs shall be eradicated. |
|
|
| Report Abuse |
|
|