Characters don't ragdoll properly

I was trying to make a ragdoll death script, but instead of the characters falling back or forward, it looks like they just sit down.

And also, sometimes after falling over, the characters keep twitching.

The script just changes the Motor6Ds to BallSocketConstraints

-- character died event, "hit" is the part that was shot before dying
for i,v in pairs(hit.Parent:GetDescendants()) do
	if v:IsA("Motor6D") then
		local att0, att1 ="Attachment"),"Attachment");
		att0.CFrame = v.C0;
		att1.CFrame = v.C1;
		att0.Parent = v.Part0;
		att1.Parent = v.Part1;

		local bleh ="BallSocketConstraint");
		bleh.Parent = v.Parent;
		bleh.Attachment0 = att0;
		bleh.Attachment1 = att1;
		bleh.LimitsEnabled = true;
		bleh.TwistLimitsEnabled = true;
		bleh.MaxFrictionTorque = 20;

		if string.match(v.Name, "Hip") or string.match(v.Name, "Shoulder") or string.match(v.Name, "Neck") then
			bleh.TwistLowerAngle = -80;
			bleh.TwistUpperAngle = 80;
			bleh.TwistLowerAngle = -40;
			bleh.TwistUpperAngle = 40;
		if string.match(v.Name, "Hip") or string.match(v.Name, "Shoulder") or string.match(v.Name, "Waist") then
			bleh.UpperAngle = 120;
			bleh.UpperAngle = 80;


hit.Velocity = (gun.Shoot.Position-hit.Position).Unit * -75;
-- i also tried :ApplyImpulse but it doesn't seem to do anything

Changing any of the limits does nothing, they sit down even with LimitsEnabled off. BreakJointsOnDeath and RequiresNeck are turned off in every character.

Any advice is appreciated

Try adding a NoCollisionConstraint to all parts so they don’t collide with each other.

Thanks! It solved some of the twitching, but not the sitting. I suppose it’s because the UpperTorso falls perfectly on the ground, without rotating, so it just stays there.
Would it be better to use CollisionGroups instead of the constraint, and disable collision between “Ragdoll” parts?

Yeah, that’s what you should do.

1 Like

Ok well, CollisionGroups worked a lot better. After a bit of limiter-tweaking, it now works pretty great. Thanks!

For a long-term solution after it was ragdolled, try to anchor the ragdolls whenever necessary(e.g. being not moving for a while). That’s a slight micro-optimization but it happens in some games.

1 Like