Why does this tween reverse for no reason?

I have a tool and I want to spin the sword at the top using a weld and tween service

But it does this

My code:

local playerService = game:GetService("Players")
local tool = script.Parent
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")

local equipped = false

local savedTween = nil

local baseCF = CFrame.new(0, 2.33, 0) * CFrame.Angles(0, 0, 0)


tool.Equipped:Connect(function()
	
	equipped = true
	
end)

tool.Unequipped:Connect(function()
	equipped = false
	if savedTween ~= nil then
		savedTween:Cancel()
		tool.Handle.FloatWeld.C0 = baseCF
	end
end)

task.spawn(function()
	while true do
		if equipped == true then


			local tween = TS:Create(tool.Handle.FloatWeld, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 1, false, 0), {C0 = tool.Handle.FloatWeld.C0 * CFrame.Angles(0, math.rad(360), 0)})
			tween:Play()
			savedTween = tween
			tween.Completed:Wait()
		else
			task.wait(0.015)
		end
		
	end
	
end)



Tool build:

image

Please help me im tiredā€¦

Maybe take it out the while look and make repeat true for the tween parameters?

Can you explain further? please

I would do it differently by using heartbeat
and adding to the y rotation every frame

local rot = 0
game:GetService("RunService").Heartbeat:Connect(Delta)
   rot += 5 * Delta
   tool.Handle.FloatWeld --> rotation thinngy
   CFrame.Angles(0,rad(rot),0)
end)

Well this is a good alternative but I would like to do it with TweenService at the moment

Well, considering you set ā€˜repeatCountā€™ to 1 hereā€¦

1 Like

Oh my god thereā€™s no way, how can I be such a buffoonā€¦

Well I did mention I was tiredā€¦

You know I was staring at your comment for a while thinking ā€œWhat does that have to do with the issue?ā€ and then it hit me.

1 Like

Lol, I was also staring at my comment thinking ā€˜wait, he said reverses. Not repeatsā€™. Guess you meant repeat?

1 Like

Yeaahh I meant repeat, this is what happens when you start scripting after getting 4 hours of sleep.

1 Like

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