Hello So I have this ragdoll script which is not working the way I want it to,some times it works, but then somestimes the avatar just stays still for awhile in this position before ragdolling.
Here is the script
local Humanoid = script.Parent:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false
Humanoid.Died:Connect(function()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
for i,v in pairs(script.Parent.RightUpperLeg:GetDescendants()) do
if v:IsA("Motor6D") then
local BallConstraint = Instance.new("BallSocketConstraint")
local Attachment1 = Instance.new("Attachment")
local Attachment2 = Instance.new("Attachment")
Attachment1.Parent = v.Part0
Attachment2.Parent = v.Part1
BallConstraint.Parent = v.Parent
BallConstraint.Attachment0 = Attachment1
BallConstraint.Attachment1 = Attachment2
Attachment1.CFrame = v.C0
Attachment2.CFrame = v.C1
BallConstraint.LimitsEnabled = true
BallConstraint.TwistLimitsEnabled = true
v:Destroy()
end
end
for i,v in pairs(script.Parent.LeftUpperLeg:GetDescendants()) do
if v:IsA("Motor6D") then
local BallConstraint = Instance.new("BallSocketConstraint")
local Attachment1 = Instance.new("Attachment")
local Attachment2 = Instance.new("Attachment")
Attachment1.Parent = v.Part0
Attachment2.Parent = v.Part1
BallConstraint.Parent = v.Parent
BallConstraint.Attachment0 = Attachment1
BallConstraint.Attachment1 = Attachment2
Attachment1.CFrame = v.C0
Attachment2.CFrame = v.C1
BallConstraint.LimitsEnabled = true
BallConstraint.TwistLimitsEnabled = true
v:Destroy()
end
end
for i,v in pairs(script.Parent.LeftLowerLeg:GetDescendants()) do
if v:IsA("Motor6D") then
local BallConstraint = Instance.new("BallSocketConstraint")
local Attachment1 = Instance.new("Attachment")
local Attachment2 = Instance.new("Attachment")
Attachment1.Parent = v.Part0
Attachment2.Parent = v.Part1
BallConstraint.Parent = v.Parent
BallConstraint.Attachment0 = Attachment1
BallConstraint.Attachment1 = Attachment2
Attachment1.CFrame = v.C0
Attachment2.CFrame = v.C1
BallConstraint.LimitsEnabled = true
BallConstraint.TwistLimitsEnabled = true
v:Destroy()
end
end
for i,v in pairs(script.Parent.RightLowerLeg:GetDescendants()) do
if v:IsA("Motor6D") then
local BallConstraint = Instance.new("BallSocketConstraint")
local Attachment1 = Instance.new("Attachment")
local Attachment2 = Instance.new("Attachment")
Attachment1.Parent = v.Part0
Attachment2.Parent = v.Part1
BallConstraint.Parent = v.Parent
BallConstraint.Attachment0 = Attachment1
BallConstraint.Attachment1 = Attachment2
Attachment1.CFrame = v.C0
Attachment2.CFrame = v.C1
BallConstraint.LimitsEnabled = true
BallConstraint.TwistLimitsEnabled = true
v:Destroy()
end
end
end)
How do I fix this?