Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tween and memory/performance question?

Asked by
Velsity 218 Moderation Voter
4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
rower86 35
4 years ago
Edited 4 years ago

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

0
So, setting the variable that had the tween stored to nil, would delete the tween? Velsity 218 — 4y
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 rower86 35 — 4y
Ad

Answer this question