How to make specific parts of the body ragdoll on death?

Hey!

So I am trying to make only the arms and head ragdoll on the players death, but not the torso or the legs. How can I do that?

Here is my script:

local humanoid = script.Parent:WaitForChild("Humanoid")

humanoid.BreakJointsOnDeath = false

humanoid.Died:Connect(function()
	for index,joint in pairs(script.Parent:GetDescendants()) do
		if joint:IsA('Motor6D') then
			local socket = Instance.new('BallSocketConstraint')
			local a1 = Instance.new('Attachment')
			local a2 = Instance.new('Attachment')
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			joint:Destroy()
		end
	end
end)

Please let me know what I can do. Thank you for your time!

Sincerely,

papahetfan

you could make a table of joints you want to replace, for example

local joints = {
 --R6 joints
 "Left Shoulder",
 "Right Shoulder",
 "Neck",

 --R15 joints
 "LeftShoulder",
 "RightShoulder",
--etc.
}

now you can do something like this:

for index,joint in pairs(script.Parent:GetDescendants()) do
	if joint:IsA('Motor6D') and table.find(joints, joint.Name) then
		--replace joint
	end
end