Hi! I made a ragdoll on death system on a ServerScriptService. When I tested it and I didn’t move my character and my camera(after spawning into the game), when I reset the character falls with the walking animation and even after waiting for more than 5 minutes, the character wouldn’t respawn.
And of course when the charatcer and camera are moving (After spawning), everything worked perfectly fine.
I don’t know how to solve this issue are there is nothing in the output because the script works normally.
local Plrs = game:GetService("Players")
Plrs.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
Char.Humanoid.BreakJointsOnDeath = false
Char.Humanoid.Died:Connect(function()
for _,v in pairs(Char:GetDescendants()) do
if v:IsA("Motor6D") then
local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
Att0.CFrame = v.C0
Att1.CFrame = v.C1
Att0.Parent = v.Part0
Att1.Parent = v.Part1
local BSC = Instance.new("BallSocketConstraint")
BSC.Attachment0 = Att0
BSC.Attachment1 = Att1
BSC.Parent = v.Parent
v:Destroy()
end
end
Char.Head.CanCollide = true
Char.HumanoidRootPart.CanCollide = true
end)
end)
end)
2 Likes
When BreakJointsOnDeath = false the character doesn’t get destroyed by Roblox when you die so Roblox will wait for the humanoid to be removed before respawning the player but in your code you ragdoll the character and leave the Humanoid and Character instance alive which means it will never respawn you - essentially you die without cleaning up.
You should use a task.delay after the ragdoll to destroy the character like so:
Char.Humanoid.Died:Connect(function()
-- your ragdoll stuff
task.delay(5, function() -- after 5 seconds destroy the character
if Plr.Character == Char then -- sanity check
Char:Destroy()
end
end)
end)
Let me know if that helps fix your problem.
Also, if you don’t want to destroy the old character you can change it to just Plr:LoadCharacter() to spawn a brand new character and the old character will no longer be controlled and will exist until you destroy it (I believe).
1 Like
Hello! unfortunately it is not working.
I wrote the script here and I don’t know if this is the right place so to be sure I am asking:
local Plrs = game:GetService("Players")
Plrs.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
Char.Humanoid.BreakJointsOnDeath = false
Char.Humanoid.Died:Connect(function()
for _,v in pairs(Char:GetDescendants()) do
if v:IsA("Motor6D") then
local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
Att0.CFrame = v.C0
Att1.CFrame = v.C1
Att0.Parent = v.Part0
Att1.Parent = v.Part1
local BSC = Instance.new("BallSocketConstraint")
BSC.Attachment0 = Att0
BSC.Attachment1 = Att1
BSC.Parent = v.Parent
v:Destroy()
end
end
Char.Head.CanCollide = true
Char.HumanoidRootPart.CanCollide = true
task.delay(5, function()
if Plr.Character == Char then
Char:Destroy()
end
end)
end)
end)
end)
Yeah that looks like it’s in the correct place.
Does your ragdoll destroy after 5 seconds?
If it doesn’t you can try remove the sanity check I did (if Plr.Character == Char)
I also looked at what was hapening, and saw that
the constraints weren’t even replaced
My bad, it it working but it respawning after ~30sec-1min
Try removing my sanity check and let me know if that fixes anything.
the “if Plr.Character == Char then” ?
I tried to remove it but it’s just doing errors
You will need to remove the other end after Char:Destroy() 
oh yes my fault.
Ok so no it is not working too
I just scroll down to set my camera in 1st person and it worked for some reason
What is your RespawnTime inside the Players attributes and what is the RejectCharacterDeletions inside the workspace attributes.
Let me clarify of what is happening now.
So when I spawn into the game after clicking on the play button, not moving anything, the character gets bugged and I just figured out that by setting my camera in 1st person in game, the character respawn normally, Or I just wait 1 min for it to respawn. And after respawing (not with Studio but in game) the bug doesn’t apply anymore.
RespawnTime: 3
RejectCharacterDeletions: Default
It is buggy on the first death but not after
Interesting, seems like there’s something else causing the initial bug.
local Plrs = game:GetService("Players")
Plrs.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
Char:WaitForChild("Humanoid") -- you can try this
Char.Humanoid.BreakJointsOnDeath = false
Char.Humanoid.Died:Connect(function()
for _,v in pairs(Char:GetDescendants()) do
if v:IsA("Motor6D") then
local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
Att0.CFrame = v.C0
Att1.CFrame = v.C1
Att0.Parent = v.Part0
Att1.Parent = v.Part1
local BSC = Instance.new("BallSocketConstraint")
BSC.Attachment0 = Att0
BSC.Attachment1 = Att1
BSC.Parent = v.Parent
v:Destroy()
end
end
Char.Head.CanCollide = true
Char.HumanoidRootPart.CanCollide = true
task.delay(5, function()
Char:Destroy()
end)
end)
end)
end)
You can try adding this, not sure if it will help.
I did it but no it’s not working too
Seems like there is something else causing the first initial issue.
I have tested the exact code I just provided in a game (R6) and it works flawlessly.
Is there any other scripts modifying the character?
2 Likes
Try the same but not moving the character and the camera ?
No this script is the only script I have for now
I don’t ragdoll - I assume because of no velocity - but I still respawn.