Hello! I was trying to make an AI but ran into issues checking when it took damage it just wouldnt do anything. After adding a print to it and it still not printing anything, google wasnt any help at all.
I've tried using :GetPropertyChange("Health") with the same result and yes I have been dealing damage on the server side not client side if u think that it the issue. I have even wrote a separate script specially to deal damage. AGAIN no results it just doesnt work... idk why
local Humanoid = script.Parent:WaitForChild("Humanoid") local OldHealth = Humanoid.Health local UnderAttack = false function RunAway() print("fired") UnderAttack = true Humanoid.WalkSpeed = 20 Humanoid:MoveTo(math.random(0,150), 0, math.random(0,150)) Humanoid.MoveToFinished:Connect(function() Humanoid.WalkSpeed = 16 UnderAttack = false end) end function RandomMove() Humanoid:MoveTo(script.Parent.PrimaryPart.Position + Vector3.new(math.random(0,100), 0, math.random(0,100))) Humanoid.MoveToFinished:Connect(function() Humanoid.WalkSpeed = 16 UnderAttack = false end) end function Multiply() wait(math.random(5,200)) local Clone = script.Parent:Clone() Clone.PrimaryPart.CFrame = script.Parent.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(5,2,0)) end function Main() if not UnderAttack then wait(math.random(10,20)) RandomMove() end end while wait() do if Humanoid.Health < 1 then script.Parent:Destroy() break end Main() end script.Parent.Humanoid.HealthChanged:Connect(function() print("fun") if Humanoid.Health < OldHealth then print("RUNNING") UnderAttack = true RunAway() OldHealth = Humanoid.Health UnderAttack = false end end)