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:
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!