So i am trying to learn a ragdoll mechanic, but i am having trouble with keeping my character alive. How i understood that my ragdoll kills my character because i destroy the “Neck” Motor6D. But without that my character won’t Ragdoll how i want. So How to fix my problem?(BTW Unset Ragdoll works fine, but Set Ragdoll kills me)
if isragdoll == true then
enemychar.Humanoid.RequiresNeck = false
for i,v in pairs(enemychar:GetDescendants()) do --Set Ragdoll
if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
local Socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = v.Part0
a2.Parent = v.Part1
Socket.Parent = v.Parent
Socket.Attachment0 = a1
Socket.Attachment1 = a2
a1.CFrame = v.C0
a2.CFrame = v.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v:Destroy()
end
end
enemychar.Humanoid.AutoRotate = false
delay(duration,function() --Unset Ragdoll
for i,v in pairs(enemychar:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
end
end
enemychar.Humanoid.AutoRotate = true
end)
end