Rotating upper torso and head with camera causes arms to bug out

Here is a video example of what my animation looks like without the code running:

Here is a video example with the code running. As you can see the arms are pointed out for some odd reason. How could I fix this?

Also for some odd reason it does not do this during the idle animation only walking and running.
This is the code:

local runService = game:GetService('RunService')
local tweenService = game:GetService('TweenService')

local neck = script.Parent:WaitForChild('Head').Neck
local humanoidRootPart = script.Parent:WaitForChild('HumanoidRootPart')
local upperTorso = script.Parent:WaitForChild('UpperTorso')
local waist = upperTorso:WaitForChild('Waist') 

local initWaist = waist.C1
local initNeck = neck.C1

local function getCameraIsOutOfBounds(y)
	y = math.deg(y)
	if math.clamp(y, -90, 90) ~= y then
		return true

	local cameraRelativeToHRP = humanoidRootPart.CFrame:ToObjectSpace(workspace.CurrentCamera.CFrame):Inverse()
	local x,y,z = cameraRelativeToHRP:ToOrientation()
	if not getCameraIsOutOfBounds(y) then
		local goalNeckC1 = initNeck * CFrame.fromOrientation(cameraRelativeToHRP:ToOrientation())
		local halfPoint = goalNeckC1:Lerp(initNeck, 0.75)
		local neckPoint = goalNeckC1:Lerp(initNeck, 0.4)
		tweenService:Create(waist,, {C1 = * CFrame.fromOrientation(halfPoint:ToOrientation())}):Play()
		tweenService:Create(neck,, {C1 = * CFrame.fromOrientation(neckPoint:ToOrientation())}):Play()
		tweenService:Create(waist,, {C1 = initWaist}):Play()
		tweenService:Create(neck,, {C1 = initNeck}):Play()

This was probably obvious but I removed the waist tween and the problem did not occur meaning it has something to do with the waist tween.

upon further research this solved my issue:

1 Like

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