Why is this ragdoll system killing the character?

Hi DevForum,

I have a ragdoll system that I’m calling on the client, but kills the player when activated, I’m not sure if it’s because I also have a BodyVelocity in the character too. Can anyone help? Thanks!

Here is the code:

local function ragdoll(character)
	for i,v in pairs(character:GetDescendants()) do
		if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
			local Socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")
			a1.Parent = v.Part0
			a2.Parent = v.Part1
			Socket.Parent = v.Parent
			Socket.Attachment0 = a1
			Socket.Attachment1 = a2
			a1.CFrame = v.C0
			a2.CFrame = v.C1
			Socket.LimitsEnabled = true
			Socket.TwistLimitsEnabled = true
			v:Destroy()
		end
	end
end

local function unRagdoll(character)
	for i,v in pairs(character:GetDescendants()) do
		if v:IsA("BallSocketConstraint") then
			v.UpperAngle = 0
			v.TwistUpperAngle = 0
			v.TwistLowerAngle = 0
			local Joints = Instance.new("Motor6D",v.Parent)
			Joints.Part0 = v.Attachment0.Parent
			Joints.Part1 = v.Attachment1.Parent
			Joints.C0 = v.Attachment0.CFrame
			Joints.C1 = v.Attachment1.CFrame
			v:Destroy()
		end
	end

	character.Humanoid.Sit = false
end
1 Like

You are removing the Motor6.

If you remove the Motor6 for the neck your characters neck is “broken” and they die.

What can I do instead of removing the Motor6D?

The ragdoll scripts I have seen always create a duplicate the character to ragdoll it.

Then they replace the character with a respawned version when turning off the ragdoll.

Try searching for Roblox ragdoll script tutorials.

1 Like

I think you can disable them through the Enabled property instead.

2 Likes

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