The character’s limbs no-clip through the ground on ragdoll. I tried fixing it but it did not work.
Here is my code:
local ragdoll = {}
local RunService = game:GetService("RunService")
local makeCollidable = {
"Right Arm",
"Left Arm",
"Right Leg",
"Left Leg"
}
function ragdoll.Start(char)
if char.Ragdoll.Value then return end
char.Ragdoll.Value = true
local hum = char.Humanoid
local root = char:FindFirstChild("HumanoidRootPart")
for i, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
a0.Parent = joint.Part0
a1.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
end
end
if not root then return end
if not root.RootJoint.Enabled then
root.RootJoint.Enabled = true
end
hum.WalkSpeed = 0
hum.JumpPower = 0
hum.PlatformStand = true
hum.AutoRotate = false
end
function ragdoll.Stop(char)
local hum = char:FindFirstChild("Humanoid")
if hum.Health <= 0 then return end
for _, v in pairs(char:GetChildren()) do
if table.find(makeCollidable, v.Name) ~= nil then
if v:FindFirstChild("Stop") then
v.Stop:Destroy()
end
end
end
hum.PlatformStand = false
for i, joint in pairs(char:GetDescendants()) do
if joint:IsA("BallSocketConstraint") then
joint:Destroy()
end
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
char.Ragdoll.Value = false
hum:ChangeState(Enum.HumanoidStateType.Ragdoll)
hum.WalkSpeed = 16
hum.JumpPower = 50
hum.AutoRotate = true
end
return ragdoll