Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my AI's script not detecting that its health is low?

Asked by 3 years ago

Hey I just have one question about my AI, whenever I change the health that is below 54 it does not say "HURT" which it is suppose too, but it does not. It basically ignores it, and says "not hurt" when it is.

while wait(2) do
        local path = game:GetService("PathfindingService"):CreatePath()
        local human = script.Parent.Humanoid
        local torso = script.Parent.Torso
        local x = math.random(-20, 20)
        local z = math.random(-20, 20)
        local newPos = torso.Position + Vector3.new(x, 0, z)
        path:ComputeAsync(torso.Position, newPos)
        if path.status == Enum.PathStatus.Success then
            local points = path:GetWaypoints()
            for i, point in pairs(points) do
                human:MoveTo(point.Position)
        end
        script.Parent.Torso.ProximityPrompt.Triggered:Connect(function(plr)
            script.Parent.Humanoid.WalkSpeed = 0
            plr.PlayerGui.GUITest.Enabled = true
        end)
    end
    script.Parent.Humanoid.Changed:Connect(function()
        if script.Parent.Humanoid.Health <= 54 then
            print("HURT")
        else
            print("not hurt")
        end
    end)
end


1
replace Changed with HealthChanged or Humanoid:GetPropertyChangedSignal("Health")? NGC4637 602 — 3y

Answer this question