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 -
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health - 1
end
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
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health - 1
local humanoid = script.Parent:WaitForChild("Humanoid")
if humanoid.Died:connect(function ()
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health - 0
end
end)
end
end
script.Parent.Touched:connect(onTouched)
