It is because you are trying to access the “Health” variable outside the humanoid.
There is a script called “Health” inside rigs so that is why you are getting that error.
‘’’
function onTouch(hit, bullet)
if hit.Parent:findFirstChild(“Zombie”) then
if hit.Parent:findFirstChild(“Zombie”).Humanoid.Health > 0 then
end
end
end
‘’’
function onTouch(hit, bullet)
if hit.Parent.Name == "Zombie" and hit.Parent:FindFirstChild("Humanoid").Health > 0 then
end
end
function onTouch(hit, bullet)
local Hit = hit.Parent
if Hit.Name == "Zombie" then
local Hum = Hit:FindFirstChild("Humanoid")
if Hum.Health > 0 then
end
end
end
function onTouch(hit, bullet)
local Hit = hit.Parent
if Hit.Name == "Zombie" then
if Hit.Humanoid.Health > 0 then
end
end
end
local db = true
function onTouch(hit, bullet)
if db then
local Hit = hit.Parent
if Hit.Name == "Zombie" then db = false
local Hum = Hit:FindFirstChild("Humanoid")
if Hum and Hum.Health > 0 then
Hum.Health -= 10
task.wait(0.33)
end db = true
end
end
end
Zombie is the name of the NPC … you will not find that within hit. It is the hits name. Once you know that is Zombie, you also know Humanoid is within that.
local debounce
local function onTouch(hit, bullet)
local character = hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if debounce and not (character.Name == "Zombie" or humanoid) then
return
end
debounce = true
humanoid:TakeDamage(10)
task.wait(0.33)
debounce = false
end```