I tried making a script where when you kill an enemy, for now it just prints that it is dead, but it doesn’t work, I have no clue about what to do. Here is my code so far.
while true do
wait()
if script.Parent.Humanoid.Health == nil then
print("dead")
end
You don’t have to - I just use a variable since I use it more than once, and putting script.Parent.Humanoid in multiple places is usually bad practice.
This line is the most important:
if humanoid.Health > 0 then humanoid.Died:Wait() end
If the humanoid is not already dead, wait for it to die. Then continue.
This catches cases where it’s already dead. It also doesn’t wait any longer than necessary for it to die.
Uh, no that code wouldn’t work, as it’s just check also, he was checking for health that’s why I used Humanoid.HealthChanged, what if he wants to check if health is 50? uh?
Health changed would work, to check if the player have died, using a constantly loop to checking would be inefficient, also, I was giving him a good way to do it, and don’t minimod, this has nothing to do you with you.
There’s no loop, there’s a single if statement. I don’t see the problem here. If it’s not dead, wait for it to die. Isn’t that the most straightforward way of making sure some humanoid is dead?
It’s an if statement, first of all. Second of all, waiting for the Died event to fire is a perfectly acceptable way of waiting for a humanoid to die. What do you mean?