Keeping Character Body On Death

  1. What do you want to achieve?
    I want to clone a player’s character into workspace when they die, keeping it there (basically a corpse).

  2. What is the issue?
    The corpse rises back to life.

  3. What solutions have you tried so far?
    I’ve tried removing the character’s Humanoid which stops the corpse from “rising back to life”, but it removes their clothes which I don’t want. I’ve also tried setting the corpse’s humanoid state to Dead, but that didn’t work either.

Here is the code I’m currently using:

local corpsesFolder = workspace:WaitForChild("Corpses")
...
player.CharacterRemoving:Connect(function(character)
	local corpse = character:Clone()
	for _, v in pairs(corpse:GetDescendants()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v, "Default")
		elseif v:IsA("Script") or v:IsA("LocalScript") then
			v:Destroy()
		end
	end
	corpse.Name = character.Name .. "Corpse"
	corpse.Parent = corpsesFolder
end)

I’ve tried to find a post about this topic, but none of them I’ve found are fully resolved. Appreciate any help!

4 Likes

Put script on StarterCharacterScript

local chr= script.Parent
local hmn= chr:waitForChild'Humanoid'
hmn.BreakJointsOnDeath= false
hmn.Died:connect(function()
	local clone= chr:clone()
	clone.Parent= workspace:WaitForChild("Corpses")
end)
1 Like

The cloned character still stands up using this.

1 Like

If you want the Corpses to not move, fix it like this:

local chr= script.Parent
chr.Archivable= true
local hmn= chr:waitForChild'Humanoid'
hmn.BreakJointsOnDeath= false
hmn.Died:connect(function()
	local clone= chr:clone()
	for k, child in pairs(clone:getChildren()) do
		wait()
		if child:isA'Script' then child:Destroy()
		elseif child:isA'BasePart' then child.Anchored= true end
	end
	clone.Parent= workspace:WaitForChild("Corpses")
end)

the corpse will be motionless there!

1 Like

I forgot to mention that I’m using a ragdoll module. I have the player’s character ragdoll when they die, and I want that to stay (so anchoring is not an option). Here’s more of the script:

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Archivable = true
		
		local Humanoid = character:WaitForChild("Humanoid")
		Humanoid.BreakJointsOnDeath = false
		Humanoid.RequiresNeck = false
		Humanoid.AutoJumpEnabled = false
	end)
	
	player.CharacterRemoving:Connect(function(character)
		local corpse = character:Clone()
		for _,v in pairs(corpse:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				v:Destroy()
			end
		end
-- Added corpse.Humanoid:Destroy() here
-- Which makes it work, but it removes their clothes
		corpse.Name = character.Name .. "Corpse"
		corpse.Parent = corpsesFolder
	end)
end)
1 Like

I ran into the same issue a few months back and came up with the following improvized solution, which I’m pretty sure isn’t the most ideal, but it’s quick enough. Apparently cloning a humanoid will make Roblox think that it’s alive despite its current state. I fixed it by putting the cloned humanoid’s health up to 100, giving it a .1 wait time and killing it again. It didn’t get back up. Try it out!

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.Archivable = true

		local Humanoid = character:WaitForChild("Humanoid")
		Humanoid.BreakJointsOnDeath = false
		Humanoid.RequiresNeck = false
		Humanoid.AutoJumpEnabled = false
	end)

	player.CharacterRemoving:Connect(function(character)
		if character.Humanoid.Health == 0 then
			local corpse = character:Clone()
			corpse.Parent = corpsesFolder
			for _,v in pairs(corpse:GetDescendants()) do
				if v:IsA("Script") or v:IsA("LocalScript") then
					v:Destroy()
				end
			end
			corpse.Humanoid.Health = 100
			corpse.Name = character.Name .. "Corpse"
			wait(.1)
			corpse.Humanoid:TakeDamage(100)
			end
	end)
end)
9 Likes

Set Humanoid.BreakJointsOnDeath to false

1 Like

You could remove all their joints(motor6ds) and see if that stops them from rising back up. I haven’t tested this but it should in theory work.

Thank you, this ended up working! Also learned that instead of destroying the Motor6D joints when the player ragdolls, I needed to disable them because Roblox would recreate them when the character was cloned. Here’s what I ended up with:

...
player.CharacterRemoving:Connect(function(character)
	local Humanoid = character:WaitForChild("Humanoid")
	if Humanoid.Health == 0 then
		local corpse = character:Clone()
		for _,v in pairs(corpse:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				v:Destroy()
			end
        end
		corpse.Name = character.Name .. "Corpse"
		corpse.Parent = corpsesFolder
		corpse.Humanoid.Health = 100
		wait(.1)
		corpse.Humanoid.Health = 0
	end
end)

Edit: If anyone has a better solution that isn’t as “Hacky” please let me know

1 Like

Bringing this topic back because sometimes the corpses are rising back up still. There has to be a better solution rather than setting their health to 100 then back to 0. Has anyone else had this problem?

1 Like

Try making a script and putting it in StarterCharacterScripts with this

local debris = game:GetService('Debris')
local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local humanoid = character:WaitForChild('Humanoid')
local bodyDisposeTime = 30

humanoid.Died:Connect(function()
	if player ~= nil and humanoid ~= nil then
		character.Archivable = true
		
		script.Parent = game.ServerScriptService
		
		local cloneChar = character:Clone()
		cloneChar.Name = player.Name.."'s Deadbody"
		
		if workspace:FindFirstChild(cloneChar.Name) then
			workspace:FindFirstChild(cloneChar.Name):Destroy()
		end
		
		wait(0.1)
		cloneChar.Parent = workspace
		
		local rootPart = cloneChar.HumanoidRootPart or cloneChar.Torso
		local clonedHumanoid = cloneChar:FindFirstChildOfClass("Humanoid")
		cloneChar:MoveTo(rootPart.Position)
		
		rootPart.Orientation = Vector3.new(90,0,0)
		clonedHumanoid.PlatformStand = true
		clonedHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		clonedHumanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
		
		for i, v in pairs(cloneChar:GetChildren()) do
			if v:IsA("BasePart") then
				v.Anchored = false
				v.CanCollide = false
			end
			if v:IsA("Script") or v:IsA("LocalScript") then
				v:Destroy()
			end
		end
			
		if cloneChar:FindFirstChild("ForceField") then
			cloneChar.ForceField:Destroy()
		end
		
		character.Parent = game:GetService("ServerStorage")
		
		debris:AddItem(cloneChar,bodyDisposeTime)
		debris:AddItem(script,bodyDisposeTime)	
		
		wait(1)
		
		if rootPart.Orientation ~= Vector3.new(90,0,0) then
			rootPart.Orientation = Vector3.new(90,0,0)
		end
	end
end)

	

also here is the link to the youtube video

Corpse system

1 Like

were you able to solve this 2 years later? Im very confused on what is causing the Character to stay standing.

You can further simplify this by doing

corpse.Humanoid:SetState(Enum.HumanoidStateType.Dead)

super late but i had this exact problem with my own ragdoll script that clones on death
Solution is to set the Humanoid’s PlatformStand to true

It also doesn’t work with PlatformStand.

thank you soo much, it was hard to force cancollide so i found this post that helped me!