Ragdoll On Death Isn't Working

Theirs no errors in the output, heres the script, also the Parent of the script is ServerScriptService.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		Char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		Char.Humanoid.Died:Connect(function()
			for _, v in pairs(Char:GetDescendats()) do
				if v:IsA("Motor6D") then
					local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC = Instance.new("BallSocketConstraint")
					BSC.Attatchment0 = Att0
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0
					
					v:Destroy()
				end
			end
			Char.HumanoidRootPart.CanCollide = false
		end)
	end)
end)
1 Like

There are only two small details:

for _, v in pairs(Char:GetDescendants()) do

and

BSC.Attachment0 = Att0
2 Likes

How did you do that Bleu thing?

I don’t know, I just copy the code, I guess it gets sometimes.

1 Like

Doesn’t Seem like it worked, same thing, No Errors in output. Do you think I should make the Parent of the script StarterCharacterScripts or keep it as ServerScriptService?

When I tried it without correcting it, I got these errors:
image
image

So if it still doesn’t work there must be something slowing it down, you could also put this in StarterCharacterScripts, it works the same.

script.Parent:WaitForChild("Humanoid").BreakJointsOnDeath = false
script.Parent.Humanoid.Died:Connect(function()
	for _, v in pairs(script.Parent:GetDescendants()) do
		if v:IsA("Motor6D") then
			local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
			Att0.CFrame = v.C0
			Att1.CFrame = v.C1
			Att0.Parent = v.Part0
			Att1.Parent = v.Part1
			local BSC = Instance.new("BallSocketConstraint")
			BSC.Attachment0 = Att0
			BSC.Attachment1 = Att1
			BSC.Parent = v.Part0

			v:Destroy()
		end
	end
	script.Parent.HumanoidRootPart.CanCollide = false
end)

lol, because it turns red? xd

Personally I prefer StarterCharacterScripts, it is more reliable.

2 Likes

I think the errors are just spelling mistakes.
getdescendants and attachments are spelled wrong
Here’s what worked for me:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		Char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		Char.Humanoid.Died:Connect(function()
			for _, v in pairs(Char:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
					Att0.CFrame = v.C0
					Att1.CFrame = v.C1
					Att0.Parent = v.Part0
					Att1.Parent = v.Part1
					local BSC = Instance.new("BallSocketConstraint")
					BSC.Attachment0 = Att0
					BSC.Attachment1 = Att1
					BSC.Parent = v.Part0

					v:Destroy()
				end
			end
			Char.HumanoidRootPart.CanCollide = false
		end)
	end)
end)
7 Likes

Didn’t work, I put it inside of StarterCharacterScript and made it a Regular script and not a local

Didn’t work, I put it inside of StarterCharacterScripts and made it a Regular script and not a local

Nothing appears in the output? Is there something delaying the script? It is activated?
You could put print in and out of the function.

1 Like

yes,
no,
yes,
when I made it so it would print if the player died and ragdolled nothing came in the output.

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:Destroy()
			print("Player Has Died and Ragdoll Was Succsesful!")
		end
	end
end)

In the script you showed me then it would look like this,

script.Parent:WaitForChild("Humanoid").BreakJointsOnDeath = false
script.Parent.Humanoid.Died:Connect(function()
	for _, v in pairs(script.Parent:GetDescendants()) do
		if v:IsA("Motor6D") then
			local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
			Att0.CFrame = v.C0
			Att1.CFrame = v.C1
			Att0.Parent = v.Part0
			Att1.Parent = v.Part1
			local BSC = Instance.new("BallSocketConstraint")
			BSC.Attachment0 = Att0
			BSC.Attachment1 = Att1
			BSC.Parent = v.Part0

			v:Destroy()
			print("Player Has Died and Ragdoll Was Succsesful!")
		end
	end
	script.Parent.HumanoidRootPart.CanCollide = false
end)

I also tried to fire this but nothing comes in the output and it doesnt work.

Look at this map and compare, there is only the baseplate, a spawnlocation and the script.
Ragdoll On Death.rbxl (28,5 KB)

1 Like

the one I made should be somewhere in the workspace or serverscriptstorate, but not inside the character

1 Like

Also this is for R6 Rigs to ragdoll, not R15

ServerScript or LocalScript?


nvm when I made it a server script, it worked!

Since the game despawns the character model when the player respawns, I simply make the ragdoll script move everything inside the character into another model. The game will despawn the character model (which is now empty), and the new model will persist. You might have to fix the camera in certain cases but this is my go to method for making them persist.

1 Like

From experience, as long as you also transfer the Humanoid over, the clothing should render as well. If you only transfer the baseparts and the shirt, the game wont think it’s a valid person to apply clothing to, so you need to also move the humanoid over.

1 Like

Yea but when I do that, the body floats up for some reason (when i mentioned having to change up stuff, i had to clone a new humanoid to remove the float, but clothing would not work), recently found a half fix, but after player respawns, the body returns to a stand up stance ( all stiff, without animation) when you step close to the ragdoll’d body

heres a link to the post (I will also post on the link as well, with video and my code:

Ultimately If I can’t figure out how to remove the glitches that go along side making the ragdoll persist, im just settle with letting it despawn on character respawn.