Rotation Tween Not Working

The script runs just fine and there aren’t any errors, but the part still doesn’t do the spin. Any help would be greatly appreciated!



local part = game.Workspace.Storage.LocalTest
local detector = part.ClickDetector
local TweenService = game:GetService("TweenService")

local Info = TweenInfo.new(
	2, --Time animating
	Enum.EasingStyle.Linear, --Easing style
	Enum.EasingDirection.Out, --Easing direction
	0, --Repetitions
	false, --Reverse post tween?
	0 --Delay time
)

local Goal = {
	CFrame = part.CFrame * CFrame.Angles(0,math.rad(360),0)
}

local AnimateScrew = TweenService:Create(part, Info, Goal)

function onClicked()
	part.ClickDetector.MaxActivationDistance = 0
	AnimateScrew:Play()
end

detector.MouseClick:Connect(onClicked)
1 Like

hi

i know my script not working

local part = game.Workspace.Storage.LocalTest
local detector = part.ClickDetector
local TweenService = game:GetService(“TweenService”)

local Info = TweenInfo.new(
2, --Time animating
Enum.EasingStyle.Linear, --Easing style
Enum.EasingDirection.Out, --Easing direction
0, --Repetitions
false, --Reverse post tween?
1 --Delay time
)

local Goal = {
CFrame = part.CFrame * CFrame.Angles(0,math.rad(360),0)
}

local AnimateScrew = TweenService:Create(part, Info, Goal)

function onClicked()
part.ClickDetector.MaxActivationDistance = 0
AnimateScrew:Play()
end

detector.MouseClick:Connect(onClicked)

bump


TweenService chooses the most effective path, and since a 360 degree turn returns back to its original position, it just goes straight to the target rotation which is the same as its original, not doing any movement

I think you could do this by using two tweens instead (one rotating to 180, and then turn an extra 180)? Or a for loop would also be good enough since you’re using Linear style

1 Like

The 180 degree thing didn’t work but I was able to use a for loop to make a slightly less smooth animation

for i=1, 20 do
	part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(18),0)
	wait(0.1)
1 Like

if you’re gonna do it this way you can do

local tweenservice = game:GetService("TweenService")

for i = 1, 360 do
	tweenservice:Create(part, TweenInfo.new(.1), {Orientation = part.Orientation + Vector3.new(0, 1, 0)}):Play()
	task.wait()
end
1 Like

This worked in solving my issue, thanks!

1 Like