Help with persistent ragdoll corpse script

I need help with two things:

  1. Removing player character
  2. Fixing floating corpse

Video:
robloxapp-20210604-2248107.wmv (1.5 MB)

Here’s my script:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		char.Humanoid.Died:Connect(function()
			char.Archivable = true
			
			local clone = char:Clone()
			clone.Name = 'Corpse'
			
			for _, v in pairs(clone: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		
			clone.Parent = workspace
		end)
	end)
end)
game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").BreakJointsOnDeath = false
		char.Humanoid.Died:Connect(function()
			char.Archivable = true
			
			local clone = char:Clone()
			clone.Name = "Corpse"
			clone.Parent = game:GetService("Workspace")
			
			for _, v in pairs(clone:GetDescendants()) do
				if v:IsA("BasePart") then
					v.Anchored = false
				end
				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.Enabled = false
				end
			end
			clone.HumanoidRootPart.CanCollide = false
			clone.Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
			
			for i, v in pairs(char:GetChildren()) do
				if v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("Accoutrement") then
					v.Parent = nil
				end
			end
		end)
	end)
end)
2 Likes