generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

How to restart dead coroutine?

Previous Thread :: Next Thread 
EradicateTheNoobs is not online. EradicateTheNoobs
Joined: 03 Feb 2012
Total Posts: 1314
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 is not online. 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
EradicateTheNoobs is not online. EradicateTheNoobs
Joined: 03 Feb 2012
Total Posts: 1314
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
EradicateTheNoobs is not online. EradicateTheNoobs
Joined: 03 Feb 2012
Total Posts: 1314
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
EradicateTheNoobs is not online. EradicateTheNoobs
Joined: 03 Feb 2012
Total Posts: 1314
24 Oct 2015 07:54 PM
omg please


The noobs shall be eradicated.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image