Trying to preserve corpse in a ragdoll script

Heya!

Just recently I’ve been at work on this Ragdoll script for a personal project I’m working on. The general effect of turning the player into a ragdoll works fine… but, here’s the problem.

When the player turns into a ragdoll upon death, I want the corpse to be preserved within a model during the round (morbidly for comedic purposes). It’s been a battle between GetChildren() and GetDescendants(), and as I managed to get all the parts together, here was the outcome:

It appears that when the model is being preserved and replicated over into another model in the workspace, only one of the accessories are replicated while the rest are not. Why is that, and what can I do to fix it?

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
	character.Humanoid.BreakJointsOnDeath = false
	
	character.Humanoid.Died:Connect(function()
		
		local newGroup = Instance.new("Model")
		newGroup.Parent = game.Workspace.CorpseGroup
		newGroup.Name = player.Name
		
		-- Create ragdoll
		for _, v in pairs(character:GetDescendants()) do
			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:Destroy()
			end
		end
		
		wait()

		-- Problem begins here
		--replicating parts
		if not character:FindFirstChild("Shirt") then
			print("No shirt")
		else
			character:WaitForChild("Shirt").Parent = newGroup	
		end
		
		if not character:FindFirstChild("Pants") then
			print("No pants")
		else
			character:WaitForChild("Pants").Parent = newGroup
		end
		
		for _,v in pairs(character:GetChildren()) do
			if v:IsA("Part") then
				v.Parent = newGroup
			end
		end
		
		
		local humanoid = character.Humanoid
		humanoid.Parent = newGroup
	end)

Another solution I’ve tried is adding an:

or v:IsA("Accessory")

But the outcome of just adding that little piece itself is no accessories being shown on the character at all.

AGAIN, the ragdoll script works fine. I’m just having a troubling time replicated all the accessories into a model and I was hoping if anybody could offer any ideas/assistance on how I can solve this issue.

2 Likes

Have you tried to clone the character?

you would need to set Archivable to true before you can.

character.Archivable =  true
1 Like

I’ve attempted this and have gotten nowhere with it. I’ve also attempted to straight up clone the character itself:

character:Clone().Parent = newgroup

Everything from the character is loaded. But the corpse spazzes out and flings up in the air. This is probably the closest I’ve ever gotten, but just a different conflict.

Did you try anchoring it when you cloned it? This could be why.

1 Like

This just solved everything. Thank you so much for the help!

1 Like