Any help on persisting dead ragdolls?

Hello, I am wondering if anyone knows how to properly make dead players persist as ragdolls without any weird glitches (like the model being stiff for some reason)

this is the code I have been using, sometimes it works flawlessly, other times it makes the dead character stiff

--char.died event in server
local m ="Model")
			m.Parent = game.Workspace

			local g = character:GetChildren()
			character.HumanoidRootPart.CanCollide = false
			for i = 1,#g do
				g[i].Parent = m

			for _, v in pairs(m:GetDescendants()) do
				if v:IsA("BasePart") then
					v:SetNetworkOwner(nil) -- was player, i changed it
				if v:IsA("Motor6D") then
					local Att0, Att1 ="Attachment"),"Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC ="BallSocketConstraint")
					BSC.Attachment0 = Att0
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0
					if v.Part1.Name ==  "Head" then
						BSC.LimitsEnabled = true
						BSC.TwistLimitsEnabled = true
					v.Enabled = false
				if v.Name == "AccessoryWeld" then
					local WC ="WeldConstraint")
					WC.Part0 = v.Part0
					WC.Part1 = v.Part1
					WC.Parent = v.Parent
					v.Enabled = false
				if v.Name == "Head" then
					v.CanCollide = true

would really like some help if anyone else has made a persisting ragdoll system

surely it can’t be impossible

There’s alot of opensource and free to use ragdolls systems, here’s one R6 Ragdoll System,

no, I am looking for someone to help with persisting ragdolls on death and any input on that is welcome.

I have already tried scouring community resources.