Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to keep dead characters?

when a humanoid dies, it stays there unless its the humanoid of a character of a player. how can i make it so when a player's character dies, the dead character stays there and nothing else is affected, meaning the player would still respawn with a new character.

i looked in a lot of places, all i see is make it so the character doesnt load and it must be done manually but that isnt what i want, i still want respawning i just want the dead character to stay there forever. i tried cloning but it wont work. pls help

3 comments

0

Clone the character on CharacterRemoving.

0

wont work, i cnat clone

0

@AlexanderYar, send the script you have to clone the character on characterremoving

1 answer

✓ Accepted answer

Not one to spoon feed. Please show us your current code to see what you have tried to do already. But anyways here you go put this as a normal Script in StarterPlayer.StarterCharacterScripts

local debrisservice = game:GetService('Debris')
local body = script.Parent
local player = game.Players:GetPlayerFromCharacter(script.Parent)
local humanoid = body:WaitForChild('Humanoid')
local bodydisposal = 30 -- Time till body is removed set to a high number if you dont want it to despawn

humanoid.Died:Connect(function()
	if player ~= nil and humanoid ~= nil then
		body.Archivable = true
		script.Parent = game:GetService("ServerScriptService")
		local cloneChar = body:Clone()
		cloneChar.Name = player.Name.."'s Deadbody"
		if game:GetService("Workspace"):FindFirstChild(cloneChar.Name) then
			game:GetService("Workspace"):FindFirstChild(cloneChar.Name):Destroy()
		end
		wait(0.1)
		cloneChar.Parent = game:GetService("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
		body.Parent = game:GetService("ServerStorage")
		debrisservice:AddItem(cloneChar,bodydisposal)
		debrisservice:AddItem(script,bodydisposal)
		wait(1)
		if rootPart.Orientation ~= Vector3.new(90,0,0) then
			rootPart.Orientation = Vector3.new(90,0,0)
		end
	end
end)

5 comments

0

Ohh why does that work though? I already tried cloning it.

0

Could you explain your code to me plss

0

Oh right i forgot to add comments my bad but what this does is clones the character renames it and sets its parent to workspace and changes the players main character to be a different character that way the player doesn't inherite the dead body and have it despawn. so upon the player dying it adds this to the debrisservice making sure the body doesnt despawn till time is up

0

The first thing you said was clone, but i couldnt ever clone it trust me i used all the techniques. What makes it possible to clone it in your code?

0

I just figured out its because of archivable. It meanst something different than what i thought. And since characters of players have it defaukt set to false, cloning jt without making archivable true wont work! For future reference

This discussion is preserved as it was. New answers, comments, and votes are closed.