Ragdoll "explodes" at high velocitys

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i just want a nice good ragdoll that works properly when being hit at any velocity

  1. What is the issue? Include screenshots / videos if possible!

as said in title, they “explode”, aka tend to seperate really far from the torso, instead of staying together as intended

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

theres only 2 posts on the forum, neither helping.
ive tried many ragdoll systems, but they all have the same issue.
ive also tried using rigid constraints to straighten them out, but that tends to fling the ragdoll.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

the code for my ragdoll module:

local module = {}

local attachmentCFrames = {
	["Neck"] = {CFrame.new(0, 1, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1), CFrame.new(0, -0.5, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1)},
	["Left Shoulder"] = {CFrame.new(-1.3, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1), CFrame.new(0.2, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1)},
	["Right Shoulder"] = {CFrame.new(1.3, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), CFrame.new(-0.2, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)},
	["Left Hip"] = {CFrame.new(-0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)},
	["Right Hip"] = {CFrame.new(0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)},
}

local ragdollInstanceNames = {
	["RagdollAttachment"] = true,
	["RagdollConstraint"] = true,
	["ColliderPart"] = true,
}
local function createColliderPart(part: BasePart)
	if not part then return end
	local rp = Instance.new("Part")
	rp.Name = "ColliderPart"
	rp.Size = part.Size/1.7
	rp.Massless = true			
	rp.CFrame = part.CFrame
	rp.Transparency = 1

	local wc = Instance.new("WeldConstraint")
	wc.Part0 = rp
	wc.Part1 = part

	wc.Parent = rp
	rp.Parent = part
end

function replaceJoints(Character,Humanoid)
	for _, motor: Motor6D in pairs(Character:GetDescendants()) do
		if motor:IsA("Motor6D") then
			if not attachmentCFrames[motor.Name] then return end
			motor.Enabled = false;
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = attachmentCFrames[motor.Name][1]
			a1.CFrame = attachmentCFrames[motor.Name][2]

			a0.Name = "RagdollAttachment"
			a1.Name = "RagdollAttachment"

			createColliderPart(motor.Part1)

			local b = Instance.new("BallSocketConstraint")
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Name = "RagdollConstraint"

			b.Radius = 0.15
			b.LimitsEnabled = true
			b.TwistLimitsEnabled = false
			b.MaxFrictionTorque = 9999
			b.Restitution = 0
			b.UpperAngle = 90
			b.TwistLowerAngle = -45
			b.TwistUpperAngle = 45

			if motor.Name == "Neck" then
				b.TwistLimitsEnabled = true
				b.UpperAngle = 45
				b.TwistLowerAngle = -70
				b.TwistUpperAngle = 70
			end

			a0.Parent = motor.Part0
			a1.Parent = motor.Part1
			b.Parent = motor.Parent
		elseif motor:IsA("BasePart") then
			--motor:SetNetworkOwner(nil)
		end
	end
	if Humanoid.Health > 0 then 
		Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
	end
	Humanoid.AutoRotate = false 
	Humanoid.JumpPower = 0
	Character:SetAttribute("LastRag", tick())
end


function resetJoints(Character,Humanoid)

	Humanoid.PlatformStand = false
	Humanoid.AutoRotate = true
	if Humanoid.Health > 0 then 
		Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	end

	if Humanoid.JumpPower == 0 then
		Humanoid.JumpPower = Character.PastJP.Value
	end

	if Character:FindFirstChild("Ragdolled") then
		Character:FindFirstChild("Ragdolled"):Destroy()

		for i,v in pairs(Character:GetChildren()) do
			if v:IsA("Folder") and v.Name == "Ragdolled" then
				v:Destroy() 
			end
		end
	end
	for _, instance in pairs(Character:GetDescendants()) do
		if ragdollInstanceNames[instance.Name] then
			instance:Destroy()
		end

		if instance:IsA("Motor6D") then
			instance.Enabled = true;
		elseif instance and instance:IsDescendantOf(workspace) and instance:IsA("BasePart") then
			if game.Players:GetPlayerFromCharacter(Character) then
				pcall(function()
					--instance:SetNetworkOwner(game.Players:GetPlayerFromCharacter(Character))
				end)
			end
		end
	end
end

function Ragdoll(value: boolean,Character,Humanoid)
	if value then replaceJoints(Character,Humanoid) else resetJoints(Character,Humanoid) end
end


module.Ragdoll = function(character, length)
	if  character:FindFirstChild("Ragdolled") then
		module.Unragdoll(character)
		task.wait(0.004)
	end

	local ragdolled = Instance.new("Folder", character)
	ragdolled.Name = "Ragdolled"
	local key = math.random(1,99999999) * math.random(1,5) / math.random(2,9)
	local HolderKey = Instance.new("NumberValue",ragdolled)
	HolderKey.Name = "Key"
	HolderKey.Value = key
	character.Humanoid.PlatformStand = true
	character.Humanoid.RequiresNeck = false
	Ragdoll(true,character,character.Humanoid)


	task.spawn(function()
		if length ~= 0 or not length and length then
			if length > 999 then
				return
			end
			task.wait(length)
			module.Unragdoll(character,key)
		end
	end)
end

module.Unragdoll = function(character,key)
	if character~=nil and character:FindFirstChild("HumanoidRootPart") then
		if key ~= nil and character:FindFirstChild("Ragdolled") and character:FindFirstChild("Ragdolled").Key.Value ~= key then return end
		local vel = character:FindFirstChild("HumanoidRootPart").Velocity
		Ragdoll(false,character,character.Humanoid)
		character:FindFirstChild("HumanoidRootPart").Velocity = vel
	end
end

return module

please help as this is a MAJOR part of the game