local Humanoid = script.Parent:FindFirstChild("Humanoid")
function findHostile()
local hostile = Humanoid:FindFirstChild("creator")
if hostile ~= nil then
if hostile.Value ~= nil then
local hostileHumanoid = hostile.Value:FindFirstChild("Humanoid")
while hostileHumanoid.Health >= 0 do
Humanoid:MoveTo(hostile.Position,hostile)
end
end
end
end
Humanoid.HealthChanged:Connect(findHostile)
It said that 'while hostileHumanoid.Health >= 0 do' tried to index a nil value with Health. Could anyone help me? This is a script under an NPC, and I'm trying to make it so that once you damage it, it follows you instantly.

1 comment
Thanks!