Weird Ragdoll Behaviors

Hello. I’ve got a ragdoll system in place, that when the Enabled function is called, the player ragdolls. This works relatively fine, apart from the fact that the torso doesn’t fall to the floor like expected.

Video Example:

Module:

local Ragdoll = {
	MotorData = {}
}

function Ragdoll.Enable(character)
	Ragdoll.MotorData[character.Name] = {}
	
	local MotorData = Ragdoll.MotorData[character.Name]
	
	for _, motor in pairs(character:GetDescendants()) do
		if motor:IsA("Motor6D") then
			MotorData[motor] = {C0 = motor.C0, C1 = motor.C1, Part0 = motor.Part0, Part1 = motor.Part1}
		end
	end
	
	character.Humanoid:ChangeState(Enum.HumanoidStateType.Seated)
	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
	
	for _, motor in pairs(character:GetDescendants()) do
		if motor:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a0 = Instance.new("Attachment")
			local a1 = Instance.new("Attachment")
			a0.CFrame = motor.C0
			a1.CFrame = motor.C1
			a0.Parent = motor.Part0
			a1.Parent = motor.Part1
			socket.Attachment0 = a0
			socket.Attachment1 = a1
			socket.Parent = motor.Part1.Parent

			motor.Part1.Velocity = Vector3.new(0, 0, 0)
			motor.Part1.RotVelocity = Vector3.new(0, 0, 0)

			motor.Enabled = false
			motor.Part0 = nil
			motor.Part1 = nil
		end
	end
end

function Ragdoll.Disable(character)
	character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)

	for motor, state in pairs(Ragdoll.MotorData[character.Name]) do
		if motor.Parent then
			motor.Part0 = state.Part0
			motor.Part1 = state.Part1
			motor.C0 = state.C0
			motor.C1 = state.C1
			motor.Enabled = true
		end
	end

	for _, part in pairs(character:GetDescendants()) do
		if part:IsA("BallSocketConstraint") then
			part:Destroy()
		elseif part:IsA("Attachment") then
			part:Destroy()
		end
	end
end

return Ragdoll

Why does this happen?

Try setting the humanoid’s EvaluateStateMachine property to false and/or the state to Enum.HumanoidStateType.Physics whenever the player should ragdoll.
IIRC one of those should fix it.

don’t you normally set PlatformStand to true

1 Like

Honestly didn’t know what EvaluateStateMachine does until I looked at it properly. (and when you reminded me of it) Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.