Can't get ragdolls to work

I’ve been trying to fix this for a while now but nothing seemed to work, it’s really strange.

when the ragdoll is applied to a dummy (owned by the server), the dummy seems to actually get ragdolled but never gets up. when the client ragdolls it’s own character the hrp and the torso fall out but the rest of the limbs stay in the air as if they are anchored (they aren’t)

if anyone has a solution for this i’d appreciate help :folded_hands::folded_hands:

footage:

the code (it’s shared by both the server and client)

local function ToggleRagdoll(Victim: Model, State: boolean)
	local Humanoid = Victim:FindFirstChildOfClass("Humanoid")
	if State then
		if Humanoid then
			Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
			Humanoid.AutoRotate = false
		end
	else
		if Humanoid then
			Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
			Humanoid.AutoRotate = true
		end
	end
	
	for _, Object: Instance in Victim:GetDescendants() do
		if IsLimb(Object) then
			if not Object:GetAttribute("OriginalCollide") then
				Object:SetAttribute("OriginalCollide", Object.CanCollide)
			end	
			
			if State then
				Object.CanCollide = true
			else
				Object.CanCollide = Object:GetAttribute("OriginalCollide")
			end
		end

		if Object:IsA("Motor6D") then
			if Object.Name == "RootJoint" then
				continue
			end
			
			local Ballsocket = Object.Part0:FindFirstChild(`RagdollSocket_{Object.Part1}_{Object.Part0}`)
			if not Ballsocket then
				Ballsocket = Instance.new("BallSocketConstraint")
				Ballsocket.Name = `RagdollSocket_{Object.Part1}_{Object.Part0}`
				Ballsocket.Parent = Object.Part0
			end

			local Attach1 = Object.Part0:FindFirstChild(`{Object}_Att1`)
			local Attach2 = Object.Part1:FindFirstChild(`{Object}_Att2`)
			if not Attach1 or not Attach2 then
				Attach1 = Instance.new("Attachment")
				Attach2 = Instance.new("Attachment")

				Attach1.Name = `{Object.Name}_Att1`
				Attach2.Name = `{Object.Name}_Att2`

				Attach1.CFrame = Object.C0
				Attach2.CFrame = Object.C1

				Attach1.Parent = Object.Part0
				Attach2.Parent = Object.Part1
			end

			Ballsocket.Attachment0 = Attach1
			Ballsocket.Attachment1 = Attach2

			Ballsocket.LimitsEnabled = true
			Ballsocket.TwistLimitsEnabled = true

			Ballsocket.Enabled = State
			Object.Enabled = not State
		end
	end
end

module.RagdollCharacter = function(Victim: Model, Duration: number)
	ToggleRagdoll(Victim, true)
	
	task.delay(Duration, function()
		ToggleRagdoll(Victim, false)
	end)
end

Could it be the fact that the attachments are defined incorrectly? (as within)

local Attach1 = Object.Part0:FindFirstChild(`{Object}_Att1`)

Maybe you should try this instead:

local Attach1 = Object.Part0:FindFirstChild(Object.Name .. "_Att1")
local Attach2 = Object.Part1:FindFirstChild(Object.Name .. "_Att2")

There is also another error that I noticed in which: the unragdoll code never restores states as the physics is being set on both ragdoll and unragdoll as within

if State then
    Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    Humanoid.AutoRotate = false
else
    Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    Humanoid.AutoRotate = true
end

You can simply fix this by doing returning the humanoid into a normal state

if State then
    -- ENABLE ragdoll
    Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    Humanoid.AutoRotate = false
else
    -- DISABLE ragdoll
    Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    task.wait()
    Humanoid:ChangeState(Enum.HumanoidStateType.Running)
    Humanoid.AutoRotate = true
end

I hope this helps.

i managed to fix the dummy, and for the player i think it doesn’t have to do with the ragdoll code itself.
i tested it without reseting and the ragdoll applied properly to the player, when reseting however the humanoidrootpart falls out and the rest of the body stays intact even though i have BreakJointsOnDeath set to false

this is all i do to handle character respawning, am i missing something?

local module = {}

local RespawnTime = 3

module.OnPlayer = function(Player: Player, PlayerData: {})
	local NewRig = module.Env.Services.CharacterLoader.CreateNew()
	local AvatarData = module.Env.GetTypes.AvatarData.Begin(Player)
	module.Env.Services.CharacterLoader.LoadAvatar(NewRig, AvatarData)
	NewRig.Name = Player.Name
	
	local Humanoid: Humanoid = NewRig.Humanoid
	if not Humanoid then
		return
	end
	
	NewRig.Parent = workspace.Main.Alive
	Player.Character = NewRig
	Humanoid.BreakJointsOnDeath = false
	
	Humanoid.Died:Once(function()
		module.Env.Services.Combat.Ragdoll(NewRig, RespawnTime)

		task.wait(RespawnTime)
		module.OnPlayer(Player, PlayerData)
	end)
end

Make sure:

  • your constraints are being created on the serverside
  • Humanoid.RequiresNeck is set to false
  • you disable GettingUp Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)

I had the same Issue with the ragdoll, to fix It you must ragdoll the dummy In the server not the client