Will localizing a tween function create a memory leak?

image

Probably a dumb question, but do I have to create some sort of manual cleanup system after CurrentTween.Completed:Wait() or will it automatically get garbage collected after the function?

1 Like

The local variable for the tween will automatically be garbage collected after the function has ended because the variable is not needed anymore.

You can read about it here:

Variant RBXScriptSignal:Wait ( )
Yields the current thread until this signal is fired. Returns what was fired to the signal.

… so there simply isn’t any mechanism for cleaning up Event:Wait() calls since they don’t create any Connection objects like Connect does.

If you want to know what can create memory leaks, check out these posts, especially the last one: