Hello. I have a faulty ragdoll script that doesn't return any errors, but does not do what it's intended to do. Every time I activate it, it always seems to kill the player instead, and I have no idea on why this is happening. I am using ball socket constraints, and maybe will start using hinge constraints later. This ragdoll script is for R6, and all of the ball socket constraints are enabled at all times btw.
local function returnMotor(joint, part, motors)
if motors:FindFirstChild(joint) then
motors[joint].Parent = part
end
end
script.Ragdoll.Event:Connect(function(bool)
if tick() - LAST_RAG < 2 then
return
end
LAST_RAG = tick()
local torso = character:WaitForChild("Torso")
local motors = ReplicatedStorage.Motors:FindFirstChild(player.Name, true)
if bool then
if knocked then
return
end
dis = create("Disable", nil, character) -- ignore
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
root.CanCollide = false
root.Massless = true
for _, bodyPart in pairs(character:GetChildren()) do -- removes all motor6Ds
if bodyPart:IsA("BasePart") then
for _, motor in pairs(bodyPart:GetChildren()) do
if motor:IsA("Motor6D") then
motor.Parent = motors
end
end
end
end
humanoid.PlatformStand = true
root.OOF:Play()
root.OOF.TimePosition = .5
humanoid.AutoRotate = false
humanoid:UnequipTools()
con2 = character.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
humanoid:UnequipTools()
end
end)
knocked = true
elseif not bool then
if not knocked then
return
end
if con2 then
con2:Disconnect()
end
if dis then
dis:Destroy()
end
humanoid.PlatformStand = false
humanoid.Jump = true
humanoid.AutoRotate = true
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
root.CanCollide = true
root.Massless = false
local rightArm = character["Right Arm"]
local leftArm = character["Left Arm"]
local rightLeg = character["Right Leg"]
local leftLeg = character["Left Leg"]
returnMotor("Neck", torso, motors)
returnMotor("RootJoint", root, motors)
returnMotor("Left Shoulder", leftArm, motors)
returnMotor("Right Shoulder", rightArm, motors)
returnMotor("Left Hip", leftLeg, motors)
returnMotor("Right Hip", rightLeg, motors)
knocked = false
end
end)

2 comments
The for loop is parenting the motors in the limbs out of the character into some other parent. When you take out the "Neck" motor, you disconnect the head from the torso which kills the character.
Now, the arms and legs fall out of the character and into the void.