I have found a way to tween between two colours.
local tween = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) local tweenOn = ts:Create(Box, tween, {ImageColor3 = onColor}) tweenOn :Play()
How do I loop this tween?
Problem 1:
The Box Gui can be destroyed as its part of an inventory and it refreshes. There is an error "Can only tween objects in the workspace" when tweens are destroyed mid tween with normal GUI tweens. How could I avoid this?
Problem 2:
Since tweens are created with :Create, is there a possibility that stacking this could cause lag? Similar to connecting events and when you don't :Disconnect them.
A tween can be setup to loop. Set its repeat count to -1.
Another solution would be to use a while loop and check if the parent is not nil.
example only
local tween = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) local tweenOn = ts:Create(Box, tween, {ImageColor3 = onColor}) while Box.Parent do -- while there is a parent tweenOn:Play() tweenOn.Completed:Wait() end
You may also want to use both methods of looping the tween and when the box parent changes stop the tween.
I hope this helps.