Why did this ragdoll script break?

Hi, I found this on the devforum and can’t get it to work again on R15.

External Media
local Char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

local function Ragdoll()
	for _, v in pairs(Char:GetDescendants()) do --Char = player.Character
		if v:IsA("Motor6D") then
			local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
			Att0.CFrame = v.C0
			Att1.CFrame = v.C1
			Att0.Parent = v.Part0
			Att0.Name = "Att0"
			Att1.Name = "Att1"

			Att1.Parent = v.Part1
			local BSC = Instance.new("BallSocketConstraint")
			BSC.Attachment0 = Att0
			BSC.Attachment1 = Att1
			BSC.Parent = v.Part0
			BSC.LimitsEnabled = true
			BSC.MaxFrictionTorque = 100
			BSC.TwistLimitsEnabled = true
			BSC.UpperAngle = 90
			BSC.TwistLowerAngle = -90	
			BSC.TwistUpperAngle = 90
			BSC.Name = "BSC"
			v.Enabled = false
		end
	end
	Char.HumanoidRootPart.CanCollide = false
end

local function Unragdoll()
	for _, obj in ipairs(Char:GetDescendants()) do
		if obj:IsA("Motor6D") then obj.Enabled = true end
		if obj:IsA("BallSocketConstraint") then obj.Attachment1:Destroy() obj.Attachment0:Destroy() obj:Destroy() end
	end
	Char.HumanoidRootPart.CanCollide = true
end

task.wait(3)

Ragdoll()

task.wait(5)

Unragdoll()