R6 torso bending

i am trying to make the torso bend when the player looks up or down

i have seen some other posts but it wont work with r6

edit:
i have this

	local HRP = Character:WaitForChild("HumanoidRootPart")
	
	local Neck = HRP:FindFirstChildOfClass("Motor6D")
	
	local YOS = Neck.C0.Y
	
	local asin = math.asin
	local CFNew, CFAng = CFrame.new, CFrame.Angles
	
	RS.RenderStepped:Connect(function()
		local Direction = HRP.CFrame:toObjectSpace(Camera.CFrame).lookVector
		
		if Neck then
			if Humanoid.RigType == Enum.HumanoidRigType.R15 then
				Neck.C0 = CFrame.new(0, YOS, 0) * CFrame.Angles(0, -math.asin(Direction.x), 0) * CFrame.Angles(math.asin(Direction.y), 0, 0)
			elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
				Neck.C0 = CFNew(0, YOS, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(Direction.x)) * CFAng(-asin(Direction.y), 0, 0)	
			end
		end
	end)

but it moves my character about randomly over the place

Hello i have tried playing with your code and i found out everything is working fine but you are suppose to to move the Torso but i found out the Toso has multiple motor6D to it which include leg and arm thus its your whole character that is Rotating i Finally get it working as you want here is a picture of the actual Player Character motor6D
Screenshot 2021-04-17 211422w
and Here is how it should be
Screenshot 2021-04-17 211342
Notice the Motor6D
here is a video of how its working in game

Edit: the leg won’t move because when moving its motor6D you are making it a new rig so the animation doesn’t animate that you probably need to re-animate it yourself

3 Likes