UI only tweens 1 time in a loop

I’ve tryed messed around with my local script and I can’t seem whats wrong with it.

What I want the script to do

  • Tween a UI part

Error I’m getting

  • Not Tweening the UI after the first loop

What I’ve tryed

  • Putting the while true do in between line 5 and 6

  • Changing the tween2:Pause() and replacing it with tween2:Cancel()


My code

  • My code is in a local script and the local script is a child of a UI
--locals--
local LoadingBox = script.Parent
local LoadingScreen = script.Parent.Parent
--
local TweenService = game:GetService("TweenService")
local tweenInfo2 = TweenInfo.new(3, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut)
local tween2 = TweenService:Create(LoadingBox, tweenInfo2, {Rotation=360})

while true do
	wait(1)
	print("In loop")
	tween2:Play()
	tween2.Completed:Wait()
	tween2:Pause()  -- I have tryed tween2:Cancel()
	tween2:Play()
end

It’s because the ‘Rotation’ of the UI is already rotated in 360, try making another Tween variable and set the Rotation value to -0.

1 Like

Ooo… Thank you! That makes sences!

while true do
	tween2:Play()
	tween2.Completed:Wait()
	LoadingBox.Rotation = 0
end

Alternatively you could make the tween reverse its animation.

TweenInfo.new(3, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, true, 0)