I was making my tweening script for an obby and it worked but the problem was my game became laggy. When I used multi lined comments on my tween script to make it stop, the game turned back to normal so I believe I have too many scripts or something is wrong with my tween script. I have one more script that tweens my GUI but it didn’t lag my game. My tween script that lags my game is shown below. I would really appreciate it if someone helped me and thank you in advance.
local part = script.Parent
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
-1,
true,
1
)
local Goals = {
Size = Vector3.new(7.01, 40, 3)
}
local Tween = TweenService:Create(part, Info, Goals)
Tween:Play()
If you are tweening lots of parts on the server then that could make things laggy. If possible move these to be in a local script so that the tweening is happening on each client, that should take away the lag
You might need to put all the parts you want to tween in a folder, or mark them up in some other way.
Then in a local script loop through all of these and start a tween for them all, it should then be smoother and not laggy
If you are tweening really huge numbers of parts you might need to do more optimising (e.g. only actually tweening things that the player is close to/can see)
The tween shouldn’t lag your game but if it does, it might be because you are tweening a huge object or that something in your tween isn’t working right.