Help with C0's Orientation

I don’t usually post in the devforums, but I am once again helpless.

I am having an issue about Tweening C0. The issue is that Orientation’s X which is supposed to be -90, is instead 90. Here is the code:

Back2 = TweenService:Create(Neck, TweenInfo.new(0.7, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {C0 = CFrame.new(0, 1.547, 0) * CFrame.Angles(math.rad(-90), math.rad(-180), 0)})
Back2:Play()

Result:
image
image

If necessary, I also have an extra code that makes the NPC’s head follow the player:

while Facing.Value == true do
			task.wait()
			Dist = (PlayerHRP.Position - PrimaryPart.Position).Magnitude 

			local dir = (PlayerHRP.Position - PrimaryPart.Position).Unit
			local vecA = Vector2.new(PrimaryPart.CFrame.LookVector.X, PrimaryPart.CFrame.LookVector.Z)
			local vecB = Vector2.new(dir.X, dir.Z)
			local dotValue = vecA:Dot(vecB)
			local crossValue = vecA:Cross(vecB)
			local ht = PrimaryPart.Position.Y - PlayerHRP.Position.Y
			local upAngle = math.atan(ht/4)

			local angle = math.atan2(crossValue, dotValue)
			if angle > math.pi/3 then
				angle = math.pi/3
			elseif angle < -math.pi/3 then
				angle = -math.pi/3
			end

			Face2 = TweenService:Create(Neck, TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {C0 = CFrame.new(Neck.C0.Position) * CFrame.Angles(-upAngle, angle, 0) * CFrame.Angles(math.rad(-90), 0, math.rad(-180))})
			Face2:Play()
			if Facing.Value == false then break end

		end

I have no idea what is causing this. If you have a solution or anything in mind, please do help me out!

1 Like

Try changing the -90 in the tween create call to 270 instead.

1 Like

Failing this, would upAngle happen to be 180 degrees (3.14 radians)?
You’re offsetting the 90 degrees by the previous CFrame.Angles call.

1 Like

I’m on mobile so I’m not sure what you’re trying to achieve here, but fyi CFrame.new() has an overload that points a part in a specific direction: CFrame.new(position, faceLocation)

1 Like

Exact same result. I forgot to mention that “Back” tween is the tween that I fire after the NPC stops looking at the player (after the player has left the area) supposedly to rotate the Head back to normal.

But for some reason, when I removed the entire head-follow script, the “Back” tween worked fine.

I’m not really familiar with the instance in question, what exactly is it? I’m gonna get put of bed rq and see if I can resolve this.

I don’t fully get your message but I am using a Motor6D to alter the head’s rotation.

Are you able to set the C0 to -90 in the inspector?

I am. I think the problem lies in the head-follow script.

Have you tried this? I believe this is the issue.

Nevermind, I fixed it by changing the 4 in local upAngle = math.atan(ht/4) to Dist, then changed the “Back” tween Angles to 90, 180, 0. Though earlier I still have no idea how 90, 180, 0 discombobulated the head. Thanks for your help!