How do i make a script that deletes itself after an npc dies?

Ooh that could be it, i think the rocket launcher and the gun uses the second method

2 Likes

Ok well try the Default sword from roblox, and tell me what happens

still nothing, i’m super lost right now

2 Likes

I can Change the script so that it works with the second method

1 Like

yeah, could you try that? I think that would work

2 Likes

Here this, try it

local Humanoid = script.Parent
local Npc = Humanoid.Parent

Humanoid.HealthChanged:Connect(function()
	if Humanoid.Health <= 0 then
		Npc:Destroy() print(Npc.Name.." Has Died")
	end
end)

You could even make it in a while true do loop, if the connect(function() isn’t working

3 Likes

still nothing, do you want the gun to try and figure out why?

2 Likes

Yes, please i need to see what the problem is, you could even send me a download to the world to see even better whats goin on

1 Like

image
Search up gun in the toolbox and insert this, then ungroup it and delete the base

2 Likes

Huh the gun doesn’t work but my sword does?, what sword did you use?

1 Like

same one you said, the roblox sword from the toolbox

2 Likes
local npc = --path to your npc here

npc.Died:Connect(function()
script:Destroy()
end)
1 Like

This sword?..image

1 Like

yep, exact one made by Roblox and named “Sword”

2 Likes

Ya thats what i have image

1 Like

Let me know if this works @TheRealpropad12

2 Likes

Can you send me a download link of the world you have?

1 Like

it does not, i’m pretty sure the humanoid health is going into the negatives

1 Like

Lua, wouldn’t that just delete the script and not the model of the character

1 Like

I’m going to send you a world I made so you can download it and test what the differences are okay?

1 Like