Recently, I have been using TweenService a lot, and I have been wondering what sort of performance issues it may cause. In a game of mine, there are on average 3 tweens playing (client-side only, of course) at a given time. Is this too much? Should I cut down on Tweens? Would it be alright to add even more? At what point would a slower device (such as an iPhone 5) begin to have issues?
(Note: The only instances in the game that are unanchored, as far as I know, are the players)
There is no problem with the number of tweens, it is just where you will handle it. If you are tweening on the server, there will be some delay and lag as it is replicating to all client.
Ahh, tweens. They are cool and fun to use, however they use quite a bit of memory compared to something like loops and CFrames. At only 3 tweens running, you won’t notice much difference from using CFrame and loops, but if you start to use more tweens, it will add up and you’ll notice memory usage going up.
Compare a tween to a loop changing the CFrame of a part over 1 second and you’ll find the tween uses slightly more memory, especially when run 100s of times (creating a new tween each time and not destroying the tween), and in my opinion if you’re looking to make your game accessible to as many devices as you can, you really want to keep memory usage down.
Like Quwanterz said, server tweens will be more jittery, which is why you should use remote events or client detection to play the tweens on the client.
I’m running 250 Tweens and it takes the memory usage from 220mb to 226mb
If I leave the game running for 10 mins with the 250 tweens running there is no memory change. I am planning on running a few thousand.
What do you think?
Also, of note. I was originally running the tweens on the server and then I changed them to local script. It changed my CPU usage from 50% to run the game to 30%. So I guess it uses more CPU to bring those tweens in from the server than it does to run them locally. Weird.