Tweening Gui rotation to be a negative number not working

local disclaimer = script.Parent:FindFirstChild('disclaimer')
local TweenService = game:GetService('TweenService')

local function rotate(rotation_angle)
	local goal = {
		Rotation = rotation_angle
	}
	
	local tweenInfo = TweenInfo.new(
		5,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	local tween = TweenService:Create(disclaimer, tweenInfo, goal)
	tween:Play()
end

while script.Parent.Enabled == true do
	rotate(10)
	wait(4)
	rotate(0)
	wait(3)
	rotate(10 * -1)
end

In the example above, I use rotate() to tween the gui to be oriented at 10 degrees, and afterward to -10 degrees. The gui, however, loops only between 0 and 10 degrees. Why is this?

Are you waiting for the tween to complete? I see the tween takes five seconds, and you’re only waiting four seconds. I know I usually I have to add

rotate.Completed:Wait()

before I can do anything else or it won’t wait for the tween

1 Like

Another solution I’ve found is changing the tween info to repeat infinitely, and then setting the position to reverse to manually (-10)

local tweenInfo = TweenInfo.new(
	math.random(4,7),
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	-1,
	true,
	0
)
1 Like