Hello guys. Mostly, I work with custom rigs. But today I have found need to work with roblox ones, and make ragdoll on death… But it is unexpectedly hard to do for me. I have rescripted movement scripts, did custom ragdoll script - nothing helps. Character either levitates in air, or after 2-3 seconds of ragdoll “Unragdolls” himself in weird way:
Can anyone tell me, what’s wrong with my ragdoll script, and how I can fix it?
local Deaths = {
Ragdoll = function(Character)
local Motors = {}
Character.HumanoidRootPart.Massless = true
for _, Object in pairs(Character:GetChildren()) do
if Object:IsA("BasePart") then
Object.CanCollide = true
for _, Motor in pairs(Object:GetChildren()) do
if Motor:IsA("Motor6D") then
local Collision = Instance.new("NoCollisionConstraint")
Collision.Name = "Collider"
Collision.Part0 = Motor.Part0
Collision.Part1 = Motor.Part1
local Att0 = Instance.new("Attachment")
Att0.CFrame = Motor.C0
Att0.Name = Motor.Part0.Name
local Att1 = Instance.new("Attachment")
Att1.CFrame = Motor.C1
Att1.Name = Motor.Part1.Name
Att0.Parent = Motor.Part0
Att1.Parent = Motor.Part1
if Motor.Part0 == Character.HumanoidRootPart then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Motor.Part0
Weld.Part1 = Motor.Part1
Weld.Parent = Motor.Parent
table.insert(Motors, Weld)
else
local Ball = Instance.new("BallSocketConstraint")
Ball.Name = Motor.Name
Ball.Name = Motor.Name
Ball.LimitsEnabled = true
Ball.UpperAngle = 45
Ball.TwistLimitsEnabled = true
Ball.TwistLowerAngle = -60
Ball.TwistUpperAngle = 60
Ball.Restitution = 0.2
Ball.Attachment0 = Att0
Ball.Attachment1 = Att1
Ball.Parent = Motor.Parent
table.insert(Motors, Ball)
end
Collision.Parent = Motor.Parent
Motor.Enabled = false
end
end
end
end
Character.HumanoidRootPart.CanCollide = false
end
}
local DeathMeta = {}
DeathMeta.__index = DeathMeta
local DeathController = setmetatable({}, DeathMeta)
function DeathMeta.KillCharacter(DeathType, Character)
Deaths[DeathType](Character)
end
return DeathController