Hello everyone. I am making an AI, no further explanation needed. Obviously I used to .MoveToFinished:Wait() function. It is simply not working. Here is the code.
local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
local target = findIntruder()
if target then
local chase = getChase()
local counter = 0
for i, sound in pairs (soundservice.Ambiences.ChaseMusics:GetChildren()) do
if sound.Playing == false then
counter += 1
end
end
if counter == #soundservice.Ambiences.ChaseMusics:GetChildren() then
chase.Playing = true
end
mode.Value = "Attack"
local nearestroom = findNearestRoom(target)
local tag = nearestroom:FindFirstChild("Favorite")
if not tag then
addFavLoc(nearestroom)
end
elseif not target then
humanoid:MoveTo(waypoint.Position)
print("move")
humanoid.MoveToFinished:Wait()
print("finish")
end
end
else
humanoid:MoveTo(destination - (hrp.CFrame.LookVector * 10)
)
end
The prints repeat over and over. There is no yield. I am almost certain that the .MoveToFinished:Wait() is broken, or the :Wait() is broken because this wont work and also I tried to use .Stopped:Wait() for an animation and it didn’t work. If I am doing something wrong, I would love to know if you have a solution.