Ragdoll script does not work properly?

I followed a tutorial online on how to script a ragdoll death, but it doesn’t seem to work. I can’t find any other solutions online. There aren’t any errors that pop up on the output, and there aren’t any past solutions on the forum. Can someone take a quick look? This is on the client in PlayerCharacterScripts.

-- [[ Services ]] --
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)	
	player.CharacterAdded:Connect(function(character)
		local playerHumanoid = character:WaitForChild("Humanoid")
		playerHumanoid.Died:Connect(function()
			playerHumanoid.BreakJointsOnDeath = false
			
			for _, v in pairs(character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local attachment0,attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
					attachment0.CFrame = v.C0
					attachment1.CFrame = v.C1
					attachment0.Parent = v.Part0
					attachment1.Parent = v.Part1
					
					local ballConstraint = Instance.new("BallSocketConstraint")
					ballConstraint.Attatchment0 = attachment0
					ballConstraint.Attatchment1 = attachment1
					ballConstraint.Parent = v.Part0
					
					v:Destroy()
				end
			end
			character.HumanoidRootPart.CanCollide = false
		end)
	end)
end)
2 Likes

I moved playerHumanoid.BreakJointsOnDeath = false to a different line. Does it now work?

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)	
	player.CharacterAdded:Connect(function(character)
		local playerHumanoid = character:WaitForChild("Humanoid")
		playerHumanoid.BreakJointsOnDeath = false
		playerHumanoid.Died:Connect(function()
			
			for _, v in pairs(character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local attachment0,attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
					attachment0.CFrame = v.C0
					attachment1.CFrame = v.C1
					attachment0.Parent = v.Part0
					attachment1.Parent = v.Part1
					
					local ballConstraint = Instance.new("BallSocketConstraint")
					ballConstraint.Attatchment0 = attachment0
					ballConstraint.Attatchment1 = attachment1
					ballConstraint.Parent = v.Part0
					
					v:Destroy()
				end
			end
			character.HumanoidRootPart.CanCollide = false
		end)
	end)
end)
3 Likes

Checkout this awesome resource: R15 / Rthro Ragdolls
It works really well with R15 characters and special packages, accessories, …

2 Likes

That did not work, unfortunately.

That it is pretty cool! However, I’ll bookmark it for later, since my game is in R6.

1 Like

I just realized I spelled attachment wrong when assigning the attachments on the ball constraint. facepalm

It works now, but the accessories don’t stay with the character. (I think I would have to program that) Also, the ragdoll seems to be stiff and if I were to reset, the character would stay upright. If it does manage to fall, it doesn’t look natural.

ragdollFail

Here is my code:

-- [[ Services ]] --
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local playerCharacter = localPlayer.Character
local playerHumanoid = playerCharacter:WaitForChild("Humanoid")

playerHumanoid.BreakJointsOnDeath = false

playerHumanoid.Died:Connect(function()
	for _, v in pairs(playerCharacter:GetDescendants()) do
		if v:IsA("Motor6D") then
			local attachment0,attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
			attachment0.CFrame = v.C0
			attachment1.CFrame = v.C1
			attachment0.Parent = v.Part0
			attachment1.Parent = v.Part1
					
			local ballConstraint = Instance.new("BallSocketConstraint")
			ballConstraint.Attachment0 = attachment0
			ballConstraint.Attachment1 = attachment1
			ballConstraint.Parent = v.Part0
					
			v:Destroy()
		end
	end
	playerCharacter.HumanoidRootPart.CanCollide = false
end)

After two days I still don’t have a clue on how to fix this ragdoll. Any help would be greatly appreciated!

I stumbled upon this module: R6 Ragdoll System thought this could be useful for you.

1 Like

Hey, I made that module! You can have a look at the meat of the coding I did here. You’re welcome to modify it any way you’d like or use my system out of the box. If you have any questions about how it works or any at all, feel free to PM me

2 Likes

Nice! I’ll probably go ahead and use this module. Hopefully, I’ll be able to make my own ragdoll system once I know what I’m doing.

Thank you @apenzijncoolenleuk1 and @Vexitory!

1 Like