Cos animation abruptly reversing direction

Currently having an important issue with a cos animation.

→ Example:

→ Code:

welds.char[1].C0 = welds.char[1].C0:Lerp(cf(0,0,0) * angles(-10,0,0) * angles(0,0+0.35*cos(sine/3),0),lerpalpha)
welds.char[2].C0 = welds.char[2].C0:Lerp(cf(0,1.5,0) * angles(0,10,0),lerpalpha)
welds.char[3].C0 = welds.char[3].C0:Lerp(cf(-1.5,-0.1,0) * cf(0,0,0+0.25*cos(sine/3)) * angles(0-20*cos(sine/3),0,0),lerpalpha)
welds.char[4].C0 = welds.char[4].C0:Lerp(cf(-0.5,-1.5,0) * cf(0,0,0+0.6*cos(sine/4)) * angles(0-29*cos(sine/3),0,0),lerpalpha)
welds.char[5].C0 = welds.char[5].C0:Lerp(cf(1.5,-0.1,0) * cf(0,0,0-0.25*cos(sine/3)) * angles(0+20*cos(sine/3),0,0),lerpalpha)
welds.char[6].C0 = welds.char[6].C0:Lerp(cf(0.5,-1.5,0) * cf(0,0,0-0.6*cos(sine/4)) * angles(0+29*cos(sine/3),0,0),lerpalpha)
			

Sine = ever increasing number (every millisecond)
Example:

while task.wait() do
   sine = sine + 1
end

cf = CFrame.new

angles = function
Example:

function angles(x,y,z)
   return CFrame.Angles(math.rad(x),math.rad(y),math.rad(z))
end

welds.char = table
Example:

function weld(p1,p2)
	local _ = Instance.new("Weld")
	_.Part0 = p1
	_.Part1 = p2
	_.Parent = p1
	
	if p2.Name == "Main" or p2.Name == "RingHandle" then
		p2.Parent.Parent = p1.Parent
	end
	
	return _
end

local welds = {
	char = {
		weld(character["HumanoidRootPart"],character["Torso"]),
		weld(character["Torso"],character["Head"]),
		weld(character["Torso"],character["Left Arm"]),
		weld(character["Torso"],character["Left Leg"]),
		weld(character["Torso"],character["Right Arm"]),
		weld(character["Torso"],character["Right Leg"]),
		legs = {
			weld(character["HumanoidRootPart"],character["Right Leg"]),
			weld(character["HumanoidRootPart"],character["Left Leg"]),
		}
	},
}

Any help appreciated!

Best, Xarciti.

1 Like

Post solved myself, incorrect values inputted into cos

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