Ragdoll Module broke randomly about a month ago

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

Figure out why my ragdoll module is doing this / how to prevent it.

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

The issue is just recently something popped up in every game of mine that uses my ragdoll module, even games I haven’t touched in 3 months. it worked fine and now it doesn’t. The legs upon ragdolling will force themselves as CanCollide = true even if they weren’t prior, I cannot change this back. Doing so immediately reverts it.
A gif of this problem:
https://gyazo.com/934bac4367703a003ba4577f1c92c725

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

I’ve tried removing the piece of code that prevents spazzing by uncancolliding to the humanoid root part. No luck, additionally i’ve tried alternating between destroying the motor or enabling it, still no luck. I’ve also yet to find any post regarding this issue in particular.

Here is the code I use as my ragdoll function for all my games:

local module = {}

local function Ragdoll(self, model)
	model.PrimaryPart.CanCollide = false 
	for _,e in ipairs(model:GetDescendants()) do
		if e:IsA("Motor6D") and e.Part0 ~= model.HumanoidRootPart  then
			local a1 = Instance.new("Attachment")
			local b = Instance.new("BallSocketConstraint")
			local a2 = a1:Clone()
			a1.CFrame = e.C0
			a2.CFrame = e.C1	
			b.Attachment0 = a1
			b.Attachment1 = a2	
			b.LimitsEnabled = true
			b.TwistLimitsEnabled = true
			e.Enabled = false	
			--e:Destroy()
			a1.Parent = e.Part0
			a2.Parent = e.Part1
			b.Parent = e.Part0
		end
	end
end

module.Ragdoll = Ragdoll;

return module

Any help would be greatly appreciated! This impacts the way my ragdoll death works and also prohibits me from doing anything pertaining to realistic ragdoll.

what are doing with the self parameter? send the lines of code where the module is called.

player.CharacterAdded:Connect(function(char)
			local hum = char:WaitForChild("Humanoid", 2)
			hum.BreakJointsOnDeath = false
			hum.Died:Connect(function()
				mod:Ragdoll(char)
			end)
end)

I just have the self parameter there so i can use : syntax with the function.