How do I make it run infinitely?

Hi,

so basically im making a gui element and when the mouse enters it, it is supposed to be tweened to a random rotation for cool effect.

the problem I’m having is that it does it once then runs a lot of tweens at the same time. This slows it down to the point that it doesn’t even seem to be moving…

How do I make it so that it runs another tween with a random position after a tween gets completed?

Thanks

while script.Parent.MouseEnter do
		task.wait()
		local randomrot = math.random(-5, 5)
		local rotti = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
		local rottween = ts:Create(script.Parent, ti, {Rotation = randomrot})
		rottween:Play()
		repeat task.wait() until rottween.Completed
	end
1 Like

Tween.Completed is an event, not a boolean

while script.Parent.MouseEnter do
		task.wait()
		local randomrot = math.random(-5, 5)
		local rotti = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
		local rottween = ts:Create(script.Parent, ti, {Rotation = randomrot})
		rottween:Play()
		rottween.Completed:Wait() -- wait for the tween to end
	end
2 Likes

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