Tween won't repeat?

Tween isn’t looping but function is. Not sure how to fix it. Code I tried down below.

TweenService = game:GetService("TweenService")



while task.wait(2) do
	print("looping")
	spininfo = TweenInfo.new(2)
	targetRotation = 360
	Spin1 = TweenService:Create(script.Parent,spininfo, {Rotation = targetRotation})
	Spin1:Play()
	Spin1.Completed:Wait()
end
1 Like

You have to reset the properties after the tween finishes for it to play again. Seems silly given your doing a 360 but alot of times roblox will switch some of the values to like -0 or 0. So the tween thinks its already done. Also make sure the variables inside the loop are local to the loop. This will ensure a brand new tween is created each time.

3 Likes

How would I do this can you direct me to a link because I have no idea how to do that

Chango local spininfo to this
local spininfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, true) – True value says if it returns back after end

If I were you id just add 360 unless you must have it so it cant go above 360

TweenService = game:GetService("TweenService")



while task.wait(2) do
	print("looping")
	spininfo = TweenInfo.new(2)
	targetRotation = 360
	Spin1 = TweenService:Create(script.Parent,spininfo, {Rotation =  Rotation  + targetRotation})
	Spin1:Play()
	Spin1.Completed:Wait()
end
3 Likes

This is eventually what I did:

TweenService = game:GetService("TweenService")



function playedtween()
	print("looping")
	local spininfo = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 30, false) 
	local targetRotation = 360
	local Spin1 = TweenService:Create(script.Parent,spininfo, {Rotation = targetRotation})
	Spin1:Play()
	wait(120)
end


playedtween()
1 Like

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