TweenService in a loop

is constant tweenservice in loop a good option or not? (will it cause lag/fps freeze or something)
for example:

game:GetService("RunService").Heartbeat:Connect(function()
    ts:Create(HealthBar, TweenInfo.new(0.1), {Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth, 0, 1, 0)}):Play()
end)
1 Like

Use:

Humanoid.HealthChanged:Connect(function()
	ts:Create(HealthBar, TweenInfo.new(0.1), {Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth, 0, 1, 0)}):Play()
end)
2 Likes

I know, but I just gave an example. My code isnt like that in reality so I’m asking if its fine to spam tweenservice in a loop or not

1 Like

It depends on the case, if this is what you want, do a check before loading the tween

1 Like

well, according to my knowledge, if you will attempt to tween something that is already being tweened, previous tween will disconnect automatically, shouldn’t it be fine then?

ps. my case isnt as one I showed in the example, its way more complex (basically a whole script handler)

1 Like

Yes, exactly, but a Loop is something that has superhuman speed, so you don’t want the system to check on its own and disconnect the previous tweens, that will certainly overload the system

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.