I have this script that basically turns the NPC body parts black upon dying, however you can see in the video that the NPC’s clothing are still visible when its dead. I want to add onto this script below that removes the humanoid’s clothing upon death. Can someone help me with this? Thanks
script.Parent.Humanoid.Died:Connect(function()
for i, v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new("Really black")
v.Material = Enum.Material.Neon
v.Velocity = Vector3.new(math.random(-100, 100), 50, math.random(-100, 100))
end
end
end)
An easier way to do this could be to create a HumanoidDescription instance with the desired body colors, no clothing or accessories, keep it in ServerStorage and call script.Parent.Humanoid:ApplyDescription(game.ServerStorage["OnDeathAppearance"])
It is simple once you understand how the search for the base parts works. As you can see in the original script, the script detects the descendants of the script’s parent once the script’s parent’s humanoid dies. It already finds all of the “BaseParts”, so all you have to do is make it find shirts, pants, and tshirts, also. This is achieved by putting “elseif” conditions inside the for i, v search.
script.Parent.Humanoid.Died:Connect(function()
for i, v in pairs(script.Parent:GetDescendants()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new("Really black")
v.Material = Enum.Material.Neon
v.Velocity = Vector3.new(math.random(-100, 100), 50, math.random(-100, 100))
elseif v:IsA("Shirt") then
v:Destroy()
elseif v:IsA("Pants") then
v:Destroy()
elseif v:IsA("ShirtGraphic") then
v:Destroy()
end
end
end)
As you can see, it finds base parts, then shirts, pants, and then tshirts, and if there is any of those three things, it destroys them.