How do you make ragdoll deaths for npcs?

I am trying to make ragdoll deaths for npc’s, and I’ve seen this script a lot of times, but whever I use it, it doesn’t work. It might be because the npc is r15 but I have no clue.

local died
local character = script.Parent
died = character.Enemy.Died:Connect(function()
	local d = character:GetDescendants()
	for i=1,#d do
		local desc = d[i]
		if desc:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local part0 = desc.Part0
			local joint_name = desc.Name
			local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
			local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
			if attachment0 and attachment1 then
				socket.Attachment0, socket.Attachment1 = attachment0, attachment1
				socket.Parent = desc.Parent
				desc:Destroy()
			end	
		end
	end
end)
2 Likes

Where are you putting this script?

2 Likes

inside of the npc
(30 characters)

2 Likes

Yeah, but in a body part of the npc?

1 Like

No, just in the npc no body part

2 Likes

Its really simple, Get the humanoid of it and do
Humanoid.BreakJointsOnDeath = false

And then do that code you did.

11 Likes