Hello! I’ve tried many things and cannot seem to get this ragdoll script to work correct it does this:
My code:
local function RagDoll(Character,waitTime)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
for _, descendant in ipairs(Character:GetDescendants()) do
if descendant:IsA("Motor6D") and descendant.Parent.Name ~= "HumanoidRootPart" then
local joint_name = descendant.Name
local part0 = descendant.Part0
local attachment0 = descendant.Parent:FindFirstChild(joint_name.."Attachment") or descendant.Parent:FindFirstChild(joint_name.."RigAttachment")
local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
if attachment0 and attachment1 then
local socket = Instance.new("BallSocketConstraint")
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.UpperAngle = 5
socket.Parent = descendant.Parent
descendant.Enabled = false
end
end
if descendant:IsA("BasePart") and descendant:FindFirstChildOfClass("Motor6D") and Character.Humanoid:GetLimb(descendant) ~= Enum.Limb.Unknown then
descendant.CanCollide = true
end
end
task.wait(waitTime)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
for i,v in ipairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
v.Enabled = true
elseif v:IsA("BallSocketConstraint") then
v:Destroy()
end
end
end