Ragdoll instantly kills player

The Objective - Create a simple ragdoll script that can toggle between ragdoll and normal.

The Problem - The player immediately dies after being ragdolled.

Haven’t really tried any solutions, as I can’t really figure out what’s wrong.

Script 1: PlayerManager (game.ServerScriptService.PlayerManager)

local RagdollHandler = require(script.Parent:WaitForChild("RagdollHandler"))

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local ragdolled = Instance.new("BoolValue")
		ragdolled.Name = "Ragdolled"
		ragdolled.Parent = character
		character:FindFirstChild("Humanoid").BreakJointsOnDeath = false
	end)
end)

Script 2: RagdollHandler (game.ServerScriptService.RagdollHandler)

local module = {}
function module.ragdoll(character)
	if character.Ragdolled.Value then return end
	character.Ragdolled.Value = true

	for i, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local att0 = Instance.new("Attachment")
			local att1 = Instance.new("Attachment")
			socket.Parent = joint.Parent
			att0.Parent = joint.Parent
			att1.Parent = joint.Parent

			att0.CFrame = joint.C0
			att1.CFrame = joint.C1

			socket.Attachment0 = att0
			socket.Attachment1 = att1
			socket.TwistLimitsEnabled = true
			socket.LimitsEnabled = true

			joint.Enabled = false
		end
	end
end

function module.unragdoll(character)
	if character.Ragdolled.Value then return end
	character.Ragdolled.Value = true

	for i, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			joint.Enabled = true
		elseif joint:IsA("BallSocketConstraint") then
			joint.Enabled = false
		end
	end
end

return module

Script 3: RagdollClient (game.StarterPlayer.StarterCharacterScripts.RagdollClient)

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local ragdolled = character:WaitForChild("Ragdolled", 3)

local function change_state()
	if ragdolled.Value then
		humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	else
		humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	end
end

I’d really appreciate if someone can help figure this issue out, I can’t really see any problem from where I’m looking…

1 Like

most likely the player dies when the ‘requiresneck’ in the humanoid is set to true, and the neck motor6d is disabled.

i suggest you to try disabling the requiresneck by a script in the ragdoll module.

1 Like

I added it to the PlayerManager, and it doesn’t kill the player anymore, but it causes the character’s limbs to just disconnect and fall into the void (excluding the torso)

1 Like

is the character you’re trying to ragdoll r6 or r15?

1 Like

It’s R6. I’m pretty sure it works for both R6 and R15, though.

1 Like

the body parts fall off due to no collision parts;

what you can do is: create parts that have cancollide off when the player isn’t ragdolled, but when the player is ragdolled set them to cancollide on.

local AttactmentData = { 
	["RA"] = {"Right Arm", CFrame.new(0, 0.5, 0), CFrame.new(1.5, 0.5, 0), CFrame.new(1.5, 0, 0)},
	["LA"] = {"Left Arm", CFrame.new(0, 0.5, 0), CFrame.new(-1.5, 0.5, 0), CFrame.new(-1.5, 0, 0)},
	["RL"] = {"Right Leg", CFrame.new(0, 0.5, 0), CFrame.new(0.5, -1.5, 0), CFrame.new(0.5, -2, 0)},
	["LL"] = {"Left Leg", CFrame.new(0, 0.5, 0), CFrame.new(-0.5, -1.5, 0), CFrame.new(-0.5, -2, 0)},
}
char = script.Parent
for asefasf, data in pairs(AttactmentData) do
	local get_limb = char:FindFirstChild(data[1])
	if get_limb ~= nil then
		get_limb.CanCollide = false
		local collision_part = Instance.new("Part")
		collision_part.Name = "ColPart"
		collision_part.Size = Vector3.new(1, 1.5, 1)
		collision_part.Transparency = 1
		local colpartclone = collision_part:Clone()
		local colpartclone_weld = Instance.new("Weld")
		colpartclone_weld.C0 = CFrame.new(0, -0.25, 0)
		colpartclone_weld.Part0 = get_limb
		colpartclone_weld.Part1 = colpartclone
		colpartclone_weld.Parent = colpartclone
		colpartclone.Parent = char
	end
end

the code here creates the collisions parts; modify the code fit in ur module, and it should work.

From where I’m looking, I’m not sure how this solves the original problem.

I was able to prevent them from falling into the void by simply enabling collisions for the limbs, but the ragdoll is to work off BallSocketConstraints, which doesn’t seem to work…

If it helps, can you elaborate what the code you’ve provided does?

1 Like

i have never used ballsocketconstraints to stop limbs from falling into the void, in my life.

i have used collision parts all the time to stop them from falling off.


my code basically CREATES the collision parts in the character and sets their cframe and welds them to the limbs.

in my opinion you should either enable collisions for limbs or add collision parts, they may be ragdolls using ballsocketcontraints, however i have always used collision parts, so.

1 Like

The ballsocketconstraints are what are used to create the ragdoll, simply giving the limbs collision on ragdoll are enough to stop them from falling into the void.

Even though the limbs don’t fall into the void now, the ballsocketconstraints don’t seem to create the ragdoll.

1 Like

have you tried looking at the dev console are there any errors or anything?

1 Like

It doesn’t show any errors, and all the items that I’m looking for do get placed where they go (from testing), but it doesn’t seem to work, and I’m not sure why.

1 Like

did you add the ‘creating collision parts’ code in your module? if yes try deleting it, and see if the char will ragdoll or not

1 Like

I used it with no change in outcome, and without it, the result still remains the same.

I feel as if the issue is somewhere within this block, but I can’t figure out what’s wrong…

	for i, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local att0 = Instance.new("Attachment")
			local att1 = Instance.new("Attachment")
			socket.Parent = joint.Parent
			att0.Parent = joint.Parent
			att1.Parent = joint.Parent

			att0.CFrame = joint.C0
			att1.CFrame = joint.C1

			socket.Attachment0 = att0
			socket.Attachment1 = att1
			socket.TwistLimitsEnabled = true
			socket.LimitsEnabled = true

			joint.Enabled = false
		end

can you like resend your whole ragdoll module? just wanna see what’s in the code again

Certainly, I’ve added a few lines to anchor/unanchor the limbs when ragdolling.

local module = {}


function module.ragdoll(character)
	if character.Ragdolled.Value then return end
	character.Ragdolled.Value = true
	
	for _,v in pairs(character:GetDescendants()) do
		if v.Name == "Head" or v.Name == "Left Arm" or v.Name == "Right Arm" or v.Name == "Left Leg" or v.Name == "Right Leg" then
			v.CanCollide = true
		end
	end

	for i, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local att0 = Instance.new("Attachment")
			local att1 = Instance.new("Attachment")
			socket.Parent = joint.Parent
			att0.Parent = joint.Parent
			att1.Parent = joint.Parent

			att0.CFrame = joint.C0
			att1.CFrame = joint.C1

			socket.Attachment0 = att0
			socket.Attachment1 = att1
			socket.TwistLimitsEnabled = true
			socket.LimitsEnabled = true

			joint.Enabled = false
		end
	end
end

function module.unragdoll(character)
	if character.Ragdolled.Value then return end
	character.Ragdolled.Value = true
	
	for _,v in pairs(character:GetDescendants()) do
		if v.Name == "Head" or v.Name == "Left Arm" or v.Name == "Right Arm" or v.Name == "Left Leg" or v.Name == "Right Leg" then
			v.CanCollide = false
		end
	end

	for i, joint in pairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			joint.Enabled = true
		elseif joint:IsA("BallSocketConstraint") then
			joint.Enabled = false
		end
	end
end

return module

try removing the collisions line, and see if the player will ragdoll then

Results in the limbs falling through the world like before.

try to ragdoll the player when the player is dead, and see if the player ragdolls at all.

(set breakjointsondeath to false)

Doesn’t seem to work on player death, either.

then it must be something wrong with your code… try to check different codes on ragdolls