Cloning the character model

I’m trying to clone the character model so when the player respawns, they can see where they last died. Whenever I try to use :Clone(), it returns nil instead of giving me a copy I can iterate over to delete attachments and local scripts from.

Is this a bug on my end, or is it a feature that will require me to manually clone the contents to a new model?

What code are you using to clone it?

local function createDeadCopy(rig)
	local clone = rig:Clone()
	for _, instance in clone:GetDescendants() do
		if instance:IsA("Attachment") or instance:IsA("LocalScript") then
			instance:Destroy()
		end
	end
	return clone
end

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.BreakJointsOnDeath = false
		
		--Placing a dead copy of player
		humanoid.Died:Connect(function()
			local deadChar = createDeadCopy(char)
			deadChar:PivotTo(char.WorldPivot)
			char:Destroy()
			deadChar.Parent = workspace
		end)
		
	end)
end)

Character models have an Archivable property (false by default) that you have to set to true before you can clone them.

2 Likes

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