Hi all,
I’m currently coding an AI that randomly walks and chases a player if they get in a certain range of the entity. However, I’m running into an issue with this part of my code:
humanoid.Humanoid.WalkSpeed = walkSpeed
humanoid.Humanoid:MoveTo(v.Position)
humanoid.Humanoid.MoveToFinished:Wait()
Where sometimes the entity would get stuck, so any code beyond humanoid.Humanoid.MoveToFinished:Wait()
would never run. I want to fix this by adding a detector in which if humanoid.Humanoid.MoveToFinished:Wait()
waits more than a certain amount of time, another section of code would run.
However, I don’t know how to get started coding this. My solution for this was this section of code
humanoid.Humanoid.WalkSpeed = walkSpeed
humanoid.Humanoid:MoveTo(v.Position)
if #humanoid.Humanoid.MoveToFinished:Wait() > 10 then
task.wait(3)
isAggrovated = false
randomWalk()
else
humanoid.Humanoid.MoveToFinished:Wait()
isAggrovated = false
end
But it returned the error “Attempt to get length of boolean value”, so any help with this would be greatly appreciated. Thanks!