So I’m trying to make when you die it clones the body and it stays for awhile before it despawns
There are no errors, but it only clones the HumanoidRootPart into the model, and no other parts. Can someone help me fix this?
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
local body = Instance.new('Model', workspace)
for i, child in ipairs(character:GetChildren()) do
if child.ClassName == 'Part' or child.ClassName == 'MeshPart' then
child.Parent = body
local clone = child:Clone()
print(clone.Name)
clone.Parent = body
body.PrimaryPart = body:FindFirstChild("HumanoidRootPart")
wait(120) -- How long it takes for the ragdoll body to dissapear
-clone:Destroy()
end
end
end)
end)
end)
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
Character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name .. " has died!")
print(Character.Parent)
local test = (Character:GetChildren())
local testing = Instance.new("Model",workspace)
for i = 1, #test do
local child = test[i]
print(child.Name)
child:Clone()
child.Parent = testing
end
end)
end)
end)
This clones all, the only issue is this orange error but does not stop the script