Zombie does damage to player when alive and when killed?
Asked by
7 years ago Edited 7 years ago
i make a zombie and when it is alive it does a certain amount of damage to a player. But when the player kills it and steps on it, it does the same amount of damage it originally did even though it died.
here is the original script for the zombie damage -
01 | function onTouched(part) |
03 | local h = part.Parent:findFirstChild( "Humanoid" ) |
07 | h.Health = h.Health - 1 |
12 | script.Parent.Touched:connect(onTouched) |
here is the script i made to make it so when the zombie dies it doesnt so any damage to the player still
-DOESNT WORK PLEASE FIX
01 | function onTouched(part) |
03 | local h = part.Parent:findFirstChild( "Humanoid" ) |
07 | h.Health = h.Health - 1 |
09 | local humanoid = script.Parent:WaitForChild( "Humanoid" ) |
10 | if humanoid.Died:connect( function () |
12 | local h = part.Parent:findFirstChild( "Humanoid" ) |
16 | h.Health = h.Health - 0 |
28 | script.Parent.Touched:connect(onTouched) |