If I have many tweens, should I create all tweens in the beginning so they can be accessed with a :Play() at all times or should I only create the tween when it is needed? Which one takes less memory/which one is the best for performance?
Creating numerous tweens will require them all to be stored in memory, but unless you have tens of thousands of tweens (if not hundreds of thousands), this shouldn't be a concern.
Performance wise, creating tweens in advance might save a tiny fraction of time (at the cost of "loading" them at some point), but this benefit might very well be eaten up by having to maintain them.
If you actually do have tens of thousands of tweens (all to be played within a short time of each other), you could try doing a stress test - have a script constantly generate tweens using one of the two methods and then increase the number of tweens being generated per frame until Roblox slows down. Then do the same thing for the other method. Then you can compare how slow Roblox is running with the two different methods (ex using frames per second), telling you which one is faster (if there's even a difference). You could also look at the performance window to get an idea of which one takes up more memory as well.
I recommend just creating them when you want to use them.
It's mostly personal preference. I usually create them when I need them so I don't have them just sitting in memory, but its also faster to reference an already created one to create a new one. Pay attention to your memory usage through /console. If you're using too much with storing Tweens, try creating them when you need them. This shouldn't be a problem though, unless "many" means in the tens of thousands.
You could try this
local Tween = game:getService("TweenService") local Tweens = {} Tweens.Tween1 = Tween.Create(your tween here) --all other tweens... --When you need to run the tweens.. for _,v in pairs(Tweens) do v:play() -- maybe.. end
Sorry if this doesn't help You could also try running the tween As soon as it made. Again sorry if this doesn't help