Why is my character ragdoll acting strangely when dying?

I have a ragdoll system that acts on players when they die, and it works on non-player models however on the player models the character spazzes out. You can see in the video below:

External Media

The first one is what is expected to happen when they die, and the second one is what actually happens.
My ragdoll script is simply using ball socket things and the same function is run on non-player models as well as player models.
The character models are exactly the same, the only difference I could find is that all the limbs are defaulted to can collide false and torso and root part are set to can collide true on the player models, while the non-player models have all parts set to can collide true.

3 Likes

Do these model utilize ordinary Humanoids? If so, attempt toggling PlatformStand on upon death.


I really have no clue how the script works. If you can, provide one.

1 Like

Yes, they do use normal Humanoids, I attempted toggling PlatformStand upon death, however it didn’t seem to fix anything.
I’m using a script I found off the dev forum since it worked however I did make some changes:

local function ragdoll(character)
	print("ragdoll")
	local d = character:GetDescendants()
	for i= 1,#d do
		local desc = d[i]
		if desc:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local part0 = desc.Part0
			local joint_name = desc.Name
			local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
			local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
			if attachment0 and attachment1 then
				socket.Attachment0, socket.Attachment1 = attachment0, attachment1
				socket.Parent = desc.Parent
				desc:Destroy()
			end	
		end
	end
end

Could it be due to the limbs being can collide off? I read that I may have to set it to can collide true every stepped since it gets set every frame.

Can you check if shaking the camera of the ragdoll actually worsen the movement? Something tells me that the ragdoll is subtly moving due to the camera.

If so, attempt implement something that “attaches” the camera to the head in a fixed orientation like in Trouble in Terrorist Town or Roblox’s version Traitor Town.

1 Like

Humanoids only hack collisions on for the HumanoidRootPart and the Head due to the need for using them for calculations on the backend, such as the downcasting that keeps them upright and above ground. Limb collisions are not hacked the same way and their collisions can be set.

1 Like

I don’t think the camera is somehow moving the character, since the camera is offsetted based off of the humanoid root part every render stepped on the client, and since the camera is’t a physical object I don’t think it could somehow affect how the character ragdolls. The ragdoll is also done on the client so I don’t think it could affect it that way either.

Would changing can collide fix the problem?

I honestly don’t know, that’s up for you to test. I haven’t tested the linked code and my suggestion essentially equated up to making your player character rigs match up to the non-player character rig.

My best guess for this behaviour has something to do with either collisions or the humanoid backend and how hacky it can be at times.

1 Like

I can’t seem to set can collide to true, no matter how I try (server and client). I tried render stepped, stepped and heartbeat but it won’t work. The only other option I have is to basically clone the character model and move the actual player model to the spawnbox I have.

1 Like

My god, turns out I’m a massive idiot and was completely ignoring a key part of code.
I was setting the humanoidrootpart position after death, I can’t describe in words how dumb I feel after discovering that one single line was messing up my whole script.
Thanks for your answers though! A massive oversight on my behalf.

4 Likes

Alright, let’s mark this the solution. Each solution marked will assist our community of developers if they have similar problems. :+1:

3 Likes