Ragdoll only starts sometimes (usually when I die midair)

Title pretty much explains it, ragdoll only starts occasionally, usually when I die midair, it almost never starts right away when I die on the ground.

The script:

local Humanoid = script.Parent:WaitForChild("Humanoid")
local HRP = script.Parent:WaitForChild("HumanoidRootPart")

Humanoid.BreakJointsOnDeath = false
Humanoid.RequiresNeck = false


script.Parent.Humanoid.Died:Connect(function()
	HRP.CanCollide = true
	HRP:SetNetworkOwner(nil)
	Humanoid.AutoRotate = false
	Humanoid.PlatformStand = true
	for i, v in pairs(script.Parent:GetDescendants()) do
		if v:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			local a0 = Instance.new("Attachment")
			local a1 = Instance.new("Attachment")
			a0.CFrame = v.C0
			a0.Parent = v.Part0
			a1.CFrame = v.C1
			a1.Parent = v.Part1
			
			socket.Parent = v.Parent
			socket.Attachment0 = a0
			socket.Attachment1 = a1
			
			v:Destroy()
		end
	end
end)

Video of problem:

I think it’s because you set the network owner to the server which is why there’s a delay, but I’m not completely sure.

1 Like

not it :cry:

I found out that the problem is when the ragdoll doesn’t start it’s because the ball socket just isn’t being added until the body stops moving, but I still don’t know how to solve it

1 Like

This is a ragdoll script I’m using for my game, try implementing it and see if it works

local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false

humanoid.Died:Connect(function()
	for index, joint in pairs(script.Parent:GetDescendants()) do
		if joint:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")

			a1.Parent = joint.Part0
			a2.Parent = joint.Part1

			socket.Parent = joint.Parent
			socket.Attachment0 = a1
			socket.Attachment1 = a2

			a1.CFrame = joint.C0
			a2.CFrame = joint.C1

			socket.LimitsEnabled = true
			socket.TwistLimitsEnabled = true
			joint.Enabled = false
		end
	end
end)

ok so has it turns out the ragdoll is only delayed if the death is caused by the client (like resetting)
I have literally no idea why that is but it works fine if I am killed by a server script. Luckily I plan on having resetting off in this game so I don’t have to worry about client deaths.
Sorry for the inconvenience, and thanks for trying to help :grin:
(Also your script had a better looking ragdoll so I’ll still mark it as solution)

1 Like

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