Im not very good at if statements so basically i have a npc called “crook”
and when it dies or its humanoid health status reaches 0, i want a certain part called “testpart”
to be destroyed.
However once it reaches 0, the part stays there so im guessing im doing something wrong with the end statement or somewhere inside… Can someone help me out here?
if game.Workspace.crook.Humanoid.Health == 0 then game.Workspace.testpart:Destroy()
Is the testpart a child of the npc? Since you are calling for Workspace.testpart to be destroyed and it isn’t I’d look into where the testpart is.
You could also put a print(“testpart destroyed”) statement after the if…Health == 0 to check to see if the script is getting that far.
Is this your entire script?
It looks to me like you have only an if statement; so even if it works, it’s only checking your condition once at the beginning of the game, and never again. Luckily, we can use what’s called an event to have code run when a certain thing happens. In this case, you want to destroy the part when the crook dies. We can use the Humanoid.Died event for this:
workspace.crook.Humanoid.Died:Connect(function() --This is one way to connect a function to an event