After NPC Ragdolls/HumanoidStateType.Physics Occasionally wont stand straight

Okay so basically I have NPCs which when they die will ragdoll using this really good ragdoll script I found on the forum:Basic R to Ragdoll Script

But it is clearly intended for Player not NPC so it has a few bugs.

The one I cant fix is that sometimes when it un-ragdolls it thinks its standing but is faceplanting
(Its animating like its standing so the NPC is just horizontal not vertical)

Before anyone says, I’ve looked at other posts before making this one and none of the solutions seem to work and a lot of the posts have not got a solution.

character.Humanoid.BreakJointsOnDeath = false
	character.Humanoid.RequiresNeck=false
	character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	for _, v in pairs(character:GetDescendants()) do  --ragdoll
		if v:IsA("Motor6D") then
			local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
			a0.CFrame = v.C0
			a1.CFrame = v.C1
			a0.Parent = v.Part0
			a1.Parent = v.Part1
			local b = Instance.new("BallSocketConstraint")
			b.Attachment0 = a0
			b.Attachment1 = a1
			b.Parent = v.Part0
			v.Enabled = false
		end
	end
	repeat wait() until InhabitantValues.Health.Value > 0 and InhabitantValues.Alive.Value == true
	
	for _,v in pairs(character:GetDescendants()) do  --unragdoll
		if v:IsA('Motor6D') then
			v.Enabled = true
		end
		if v.Name == 'BallSocketConstraint' then
			v:Destroy()
		end
		if v.Name == 'Attachment' then
			v:Destroy()
		end
	end
	character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
	character.Humanoid:GetState()
	repeat 
		wait(.1) 
		character.Humanoid.Jump = true
		local State = character.Humanoid:GetState()
	until (State ~=Enum.HumanoidStateType.Freefall) and (State ~=Enum.HumanoidStateType.Jumping) 
	
	character.Humanoid.BreakJointsOnDeath = true
	character.Humanoid.RequiresNeck = true
end

(I added the repeat untill standing function, it doesn’t work )

Thanks for Reading ~ Anon

1 Like

Hey there. Author of that the post here. Yep, not gonna lie, it has a lotta bugs and I don’t intend to fix them (Since there is another free script which is miles better). I’ve come to know that Humanoid state types are a big can of worms. Changing them on the server is very unreliable, and eventually stops working at one point. That’s why the humanoid state changing stuff is done locally in that post while the ragdolling stuff is done on server (although there is a better way than this). Did you place your code in a server script?

It is a server script in the NPC.

If you have a better ragdoll script can you link me it and I might just be able to solve it myself?

(Id write one myself but I know nothing about Joints/HumanoidProperties and it’ll probably be more broken than the free code up top ) - Edit

Thanks

1 Like

R15 / Rthro Ragdolls This is the one I use for my R15 ragdolling needs. Here’s a file EchoReaper’s RToRagdoll.rbxl (41.9 KB)

Hey! I also made a ragdoll module. Might fulfil your needs!