so uh yeah i tried this before in some games and it working and since recently its not working my code is:
`script.Parent.Humanoid.Died:Connect(function() head:Destroy() torso:Destroy() hrp:Destroy() tla:Destroy() tra:Destroy() tll:Destroy() trl:Destroy() mla:Destroy() mra:Destroy() mll:Destroy() mrl:Destroy() bla:Destroy() bra:Destroy() bll:Destroy() bll:Destroy() end)`
im using it to destroy npcs tho new scripter here
oh yeah if u ask why are those things head,hrp or something, i made them variables :D
Although you have the right idea, you cannot just type 'torso' or 'head' and the script automatically picks up on what you mean. You have to define on what you want to delete, also instead of using lines of code you can actually use a loop for this.
local NPC = script.Parent local Humanoid = NPC:WaitForChild('Humanoid') Humanoid.Died:Connect(function() for _,v in pairs(NPC:GetChildren()) do if v:IsA('BasePart') or v:IsA('MeshPart') or v:IsA('UnionOperation') -- check if its a part v:Destroy() -- destroy any parts found end end end)
If you have any other questions feel free to comment below.
uh i guess i need to give the full script ;-;
local walk = script.Parent.Humanoid:LoadAnimation(script.Walking) local throw = script.Parent.Humanoid:LoadAnimation(script.Throw) local head = script.Parent.Head local torso = script.Parent.Torso local hrp = script.Parent.HumanoidRootPart local tla =script.Parent.TopLeftArm local tll = script.Parent.TopLeftLeg local mla = script.Parent.MidLeftArm local mll = script.Parent.MidLeftLeg local bla = script.Parent.BotLeftArm local bll = script.Parent.BotLeftLeg local tra = script.Parent.TopRightArm local trl = script.Parent.TopRightLeg local mra = script.Parent.MidRightArm local mrl = script.Parent.MidRightLeg local bra = script.Parent.BotRightArm local brl = script.Parent.BotRightLeg wait(0.001) walk:Play() while true do wait(10) local e = Instance.new("Part",workspace) e.Shape = "Ball" e.Material = "Neon" e.Size = Vector3.new(18.93, 18.93, 18.93) e.BrickColor = BrickColor.new("Really red") e.CFrame = tla.CFrame local f = Instance.new("Part",workspace) f.Shape = "Ball" f.Material = "Neon" f.Size = Vector3.new(18.93, 18.93, 18.93) f.BrickColor = BrickColor.new("Really red") f.CFrame = tra.CFrame wait(0.0001) local eweld = Instance.new("Motor6D",e) eweld.Part0 = e eweld.Part1 = tla local fweld = Instance.new("Motor6D") fweld.Part0 = f fweld.Part1 = tra wait(0.0001) throw:Play() wait(0.5) eweld:Destroy() fweld:Destroy() e.Touched:Connect(function(p) if p.Parent:FindFirstChild("Humanoid") then p.Parent.Humanoid.Health = p.Parent.Humanoid.Health -10 e:Destroy() end end) f.Touched:Connect(function(p) if p.Parent:FindFirstChild("Humanoid") then p.Parent.Humanoid.Health = p.Parent.Humanoid.Health -10 f:Destroy() end end) end `script.Parent.Humanoid.Died:Connect(function() head:Destroy() torso:Destroy() hrp:Destroy() tla:Destroy() tra:Destroy() tll:Destroy() trl:Destroy() mla:Destroy() mra:Destroy() mll:Destroy() mrl:Destroy() bla:Destroy() bra:Destroy() bll:Destroy() bll:Destroy() end)
from line 61 to line 76 is the problem. `
if brl isn't the issue,as its spaced out. Here's a simple way I delete body parts when you click a button:
Using Local Script:
meep = game.Players.LocalPlayer.Character script.Parent.MouseButton1Click:Connect(function() meep.Head:Destroy() meep.Torso:Destroy() end)
it destroys the local player's head and torso (R6) . Hopefully this example helps you.