you can clone the character as long as you enable Archivable
local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
for index,joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint:Destroy()
end
end
task.wait(game:GetService("Players").RespawnTime)
script.Parent.Archivable = true
local Ragdoll = script.Parent:Clone()
if Ragdoll:FindFirstChild("Health") then
Ragdoll.Health:Destroy()
end
Ragdoll.Parent = workspace -- replace this with your debris folder
Ragdoll.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
Ragdoll.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
end)
That works for the most part but it has a lot of issues.
For example the ragdoll only clones every few tries. And when it does clone, after a few seconds the humanoid stands up causing the ragdoll to do a funny dance looking thing.
I think this is due to the way the script was structured, causing it to be unreliable.
Is there a better way to clone the ragdoll instead of waiting the respawn time?