|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|