I haven’t really messed around with ragdolls so this is a first for me. I’m having an issue where after the player dies there is a short delay then the player’s accessories fall off. Did I forget to add something or is there something that needs to be fixed?
Here’s a GIF of the issue: https://gyazo.com/e6b1c08c68be099252098021344d603d
And here’s my code (fired on death):
local function ragdollCharacter(character)
coroutine.resume(coroutine.create(function()
local descendants = character:GetDescendants()
character:WaitForChild("HumanoidRootPart").CanCollide = false
for i, part in pairs(descendants) do
if part:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local part0 = part.Part0
local joint = part.Name
local attachment0 = part.Parent:FindFirstChild(joint .. "Attachment") or part.Parent:FindFirstChild(joint .. "RigAttachment")
local attachment1 = part0:FindFirstChild(joint .. "Attachment") or part0:FindFirstChild(joint .. "RigAttachment")
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = part.Parent
part:Destroy()
end
end
end
end))
end
2 Likes
Your ragdoll doesn’t even work lol, try using mine (which I had to write and it took a bit of time)
local function ragdoll(c)
for _, v in pairs(c:GetDescendants()) do
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Part0
v:Destroy()
for e, v in pairs(c:GetChildren()) do
if v:IsA("Part") then
v.CanCollide = true
end
end
end
end
c.Head.CanCollide = true
c.HumanoidRootPart.CanCollide = false
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(ch)
ch.Humanoid.BreakJointsOnDeath = false
ch.Humanoid.Died:Connect(function()
ragdollCharacter(ch)
end)
end)
end)
(Put this in a Script and put that script in ServerScriptService)
1 Like
I’ll give this a test and edit the post when I’ve finished. By the way, my script does work, I just forgot to mention that it sets BreakJointsOnDeath
outside of the function.
1 Like
Ah ok, didn’t know that lol.
Also I hope I helped too.
I just tested it and my player’s accessories still fall off. Both scripts function very similarly too, do basically the same thing. Is it because I’m handling it client side (even though it still replicates to the server)? This shouldn’t cause any issues, but I don’t know.
I told you to use a script not a localScript, read my post again.
Also my one doesn’t make my stuff fall off so I dunno if it’s broken for you.
I mean, I don’t think I have any accessories…
this is the ragdoll script i have works fine:
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
c.Humanoid.BreakJointsOnDeath = false
c.Humanoid.Died:Connect(function()
for _, v in pairs(c:GetDescendants()) do
if v:IsA("Motor6D") then
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = v.C0
a1.CFrame = v.C1
a0.Parent = v.Part0
a1.Parent = v.Part1
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Parent = v.Parent
v:Destroy()
end
end
c.HumanoidRootPart.CanCollide = false
end)
end)
end)
edit: fixed
this one doesnt have any issues for me put it in a server script in server script service
I’m aware of this, but I was hoping to handle it client side, if possible. It would seem that running it in a LocalScript, even though it replicates, causes the accessories to fall off. I have it working running off of the server but the annoying thing with running it from the server is with high ping the character doesn’t ragdoll for a visible amount of time looking like this:

Is there a reason why the accessories fall off when handled on the client?
Dont handle it client side, it can cause issues like this
Yes, that is apparent, but I asked why do the accessories fall off when handled on the client?
Alright, thank you for your input.
1 Like