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
 

Re: How to property dispose of a coroutine?

Previous Thread :: Next Thread 
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
16 Dec 2014 12:49 PM
I'm working on a GUI game. When a button is clicked, a coroutine is created in the following fashion:

coroutine.wrap(function()
...
coroutine.yield()
end)()

I noticed that as I continue to click the button, the "Rate" under the script performance tab skyrockets. I'm certain this is because of the coroutines. How can I properly dispose of a coroutine?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 Dec 2014 01:05 PM
Remove any connections to it, yield it and set anything linking it to something else/nil
Look at cleaning up variables in Lua. I like to avoid coroutines if possible.

Using Spawn() might help instead, since that has access to the C library and hopefully cleans itself up.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
16 Dec 2014 01:10 PM
I switched to spawn and I'm still getting the same thing

this is my code, its pretty simple

--label gets created
Spawn(function()
repeat
label.Position = label.Position - UDim2.new(0, 0, 0, 2)
label.TextTransparency = label.TextTransparency + 0.05
wait()
until label.TextTransparency >= 1
label:Destroy()
end)
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
16 Dec 2014 01:22 PM
okay wtf i resorted to using tween position and it stopped

HOWEVER WHEN I ADDED THE FOLLOWING REPEAT LOOP IN THE CALLBACK IT STARTED HAPPENING AGAIN D:

label:TweenPosition(
label.Position - UDim2.new(0, 0, 0, 100),
Enum.EasingDirection.Out,
Enum.EasingStyle.Quad,
1,
false,
function()
repeat
label.TextTransparency = label.TextTransparency + 0.05
wait()
until label.TextTransparency >= 1
label:Destroy()
end
)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 Dec 2014 01:47 PM
Try my tween library dude. It supports plainvalue tweens like Transparency and works Async
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