How do I destroy my characters Torso in a more complicated way? Serious answers please, this is for science.
--We begin by declaring a variable to store the character’s torso
local torso = game.Players.LocalPlayer.Character.Torso
--We then define a function which will be responsible for the actual deletion of the torso
function deleteTorso()
--We start by checking if the torso exists
if torso then
--We then use a for loop to loop through all the children of the torso
for _, child in pairs(torso:GetChildren()) do
--We check if the child is a Part or a Mesh
if child:IsA("Part") or child:IsA("Mesh") then
--If it is, we set its Parent to nil
child.Parent = nil
end
end
--We then use a recursive function to delete all descendants of the torso
function deleteDescendants(parent)
--We start by checking if the parent exists
if parent then
--We then use a for loop to loop through all the children of the parent
for _, child in pairs(parent:GetChildren()) do
--If the child is a Part or a Mesh we set its Parent to nil
if child:IsA("Part") or child:IsA("Mesh") then
child.Parent = nil
end
--We then call the recursive function on the child
deleteDescendants(child)
end
end
end
--We call the recursive function on the torso
deleteDescendants(torso)
--We then set the torso’s Parent to nil
torso.Parent = nil
end
end
--We then call the deleteTorso() function
deleteTorso()

1 comment
Why don't you just use if torso then torso:Destroy() end