Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tween and memory/performance question?

If I were to store a tween to a variable, using tweenservice:Create, and then setting the variable that holds that tween to nil, would the tween that just was created still be stored somewhere and taking up memory or worsening the performance?

If not, would it be better to use one script to create a new tween each time a door is opened, or create all the tweens in the doors in the beginning and using them?

1 answer

The tween will only be stored as long as you have a reference to it, if you had a local variable underneath a function, loop, if statement, etc. those are not global to the entire script and will allow the tween to be garbage collected since there is no reference to it after the "end" is executed

2 comments

0

So, setting the variable that had the tween stored to nil, would delete the tween?

0

Sorry for the late reply but yes if you changed the variable to nil, then the tween will be garbage collected and you wont have to worry about it

This discussion is preserved as it was. New answers, comments, and votes are closed.