Npc doesn't deal damage if npc health changes

i don’t see anything wrong with this script and it doesn’t say errors about this script…

Indexing hierarchy is very costly, please create variables for that instead;
Avoid using wait() and instead use task.wait()

Is this script under HumanoidRootPart as i understood?
hit.Parent:WaitForChild() is stuipid becouse you better wrap it in a variable in the first place+it could cause weird behavior and possible infinete yielding

local humanoid:Humanoid? = hit.Parent:FindFirstChild("Humanoid")
if humanoid==nil then return end
--Your debounce code

How about using :TakeDamage() on humanoid?

1 Like

i want to ask something, what is the 2nd humanoid for in the variable? what does that mean

you are talking about “Humanoid?”
Its a type checking Type checking - Luau
“Humanoid” stands for Humanoid Instance and “?” stands for “or nil” there so saying: variable will be either humanoid or nil

wait its, if hum == nil then return end, but its shorter?

i did that becouse touch event could (and will) fire even if it doesnt touches other humanoid

oh, but does local hum:humanoid? still mean that tho, i tested it and it worked like hum = nil return end