Ragdoll went flying

So, i want to make a ragdoll without the player dying first. but then this happen

The issue is, the ragdoll went flying, i don’t know why that happen

i searched the devforum, but didn’t found anything related to this, so im asking on how to fix it?

Video Proof: https://youtu.be/V0Qlz1A-H0I

Codes :

local character2 = script.Parent
character2.ChildRemoved:Connect(function(child)
if not character2:FindFirstChild(“Ragdoll”) then
for i,v in pairs(workspace:GetChildren()) do
if v.Name == character2.Name…“Ragdoll” then
character2.Humanoid.Health = v.Humanoid.Health
character2:SetPrimaryPartCFrame(v.PrimaryPart.CFrame)
character2.PrimaryPart.Anchored = false
v:Destroy()
local resetcam = game.ReplicatedStorage.ResetCam:Clone()
resetcam.Parent = character2
game.Debris:AddItem(resetcam,0.1)
end
end
end
end)
character2.ChildAdded:Connect(function(child)
if child.Name == “Ragdoll” and not workspace:FindFirstChild(character2.Name…“Ragdoll”) then
local humanoid = character2:Clone()
humanoid:FindFirstChild(“RagdollScriptLife”):Destroy()
humanoid:SetPrimaryPartCFrame(character2.PrimaryPart.CFrame)
humanoid.Name = character2.Name…“Ragdoll”
humanoid.Parent = workspace
for i,v in pairs(humanoid:GetChildren()) do
if v:IsA(“Part”) or v:IsA(“MeshPart”) or v:IsA(“UnionOperation”) then
v.Anchored = false
end
end
character2.PrimaryPart.Anchored = true
character2:SetPrimaryPartCFrame(character2.PrimaryPart.CFrame * CFrame.new(0,100000,0))
local character = humanoid
character.Humanoid.Health = character2.Humanoid.Health
character.Humanoid.BreakJointsOnDeath = false
local d = character:GetDescendants()
for i=1,#d do
local desc = d[i]
if desc:IsA(“Motor6D”) then
local socket = Instance.new(“BallSocketConstraint”)
local part0 = desc.Part0
local joint_name = desc.Name
local attachment0 = desc.Parent:FindFirstChild(joint_name…“Attachment”) or desc.Parent:FindFirstChild(joint_name…“RigAttachment”)
local attachment1 = part0:FindFirstChild(joint_name…“Attachment”) or part0:FindFirstChild(joint_name…“RigAttachment”)
if attachment0 and attachment1 then
socket.Attachment0, socket.Attachment1 = attachment0, attachment1
socket.Parent = desc.Parent
desc:Destroy()
end
end
end
for i,v in pairs(character:GetDescendants()) do
if v:IsA(“Motor6D”) then
v:Destroy()
end
end
end
end)

2 Likes

I think it’s because the head has to be above the neck, or it’ll keep pushing on the player until it gets the head back on.

2 Likes

So… should i make everything becomes ragdoll except the head?

2 Likes

You can use the Humanoid.BreakJointsOnDeath property. (Dunno why there’s no docs for this). If you set it to false the Humanoid will not fall apart when it dies. Then you can create BallSocketConstraints connecting each piece of the player to eachother.

To do this, you’ll want the position in the middle position between their arms to be the center of orientation. Both attachments’ positions will determine the center of rotation for the parts (both attachments will connect in the same location). You’ll want the WorldPosition of both attachments to be the center point between the upper arm and lower arm as well as the hands for R15 characters. You’ll want the upper arm and upper torso to connect at the shoulders. Pretty much the Position of the attachment determines the point at which one part will connect to the other.

Once you’ve done that you can remove the Motor6Ds in their Torso (for R6) or their arm parts and leg parts (R15). This will remove the old connections and allow the ball joints to take over. Finally, to prevent the character from being removed when the player respawns you can reparent the old character model to the workspace when the player respawns (Player.CharacterAdded will tell you when this happens and you can use Player.CharacterAdded:Wait() to wait for this to happen).

R15 characters have attachments in them determining their shoulder, hip, etc positions so it’s easy to do this for R15 characters.

2 Likes

There’s no reason not to try it, or, at least experiment with it. Don’t save, just in case.

2 Likes

Thanks! now it’s fixed! :smiley:

1 Like