I am trying to create a simple script inside of an NPC, where when it dies the pieces will disappear after 3 seconds. However i am getting the error attempt to index nil with 'GetChildren' in my script and i can't figure it out:
local function dead()
wait(3)
for i,v in pairs(script.Parent:GetChildren()) do
v:Destroy()
end
end
humanoid.Died:Connect(dead)
The script is inside of the NPC, so the parent would be the model. There is no reason (that i know of) that it should be nil. Any help is appreciated!!!

1 comment
To add on to this, by destroying everything under the Model, you're leaving the empty model in the workspace. Why not just call
script.Parent:Destroy()?