Humanoid.MovetoFinished not working properly?

as you can see in the video ive made a tds style game where zombies move to a set of waypoints
but its Humanoid.MovetoFinished isnt working as intended
heres the script

local zombie = script.Parent
local waypoints = workspace.Waypoints

for i,v in ipairs(waypoints:GetChildren()) do
	zombie.Humanoid:MoveTo(v.Position)
	zombie.Humanoid.MoveToFinished:Wait()
end

image

theyre also going the wrong direction

The waypoint objects are probably not ordered in the way that you want when you go to iterate through them.

Try this instead:


for i = 1, #waypoints:GetChildren() do
zombie.Humanoid:MoveTo(waypoints[tostring(i)].Position)
zombie.Humanoid.MoveToFinished:Wait()
end

it did help a bit, they are going in the right direction but humanoid.MoveToFinished:Wait() still doesnt work and theyre still not going at waypoint 1 (what i mean is that they start going to the next waypoint early)

I’ve heard it not being very reliable. You could transition to a distance check instead, might work better for you.

local function isAtWaypoint(waypoint)
    return (script.Parent.PrimaryPart.Position - waypoint.Position).Magnitude < 4
end

for i = 1, #waypoints:GetChildren() do
    local waypoint = waypoints[tostring(i)]
   
    while not isAtWaypoint(waypoint) do 
        zombie.Humanoid:MoveTo(waypoint.Position)
        task.wait() 
    end
end

now they dont move at all, maybe there is something else wrong, i have seen a devforum having to do with network ownership or something i dont really know

it also couldve been because im pivoting the zombie to the zombie’s spawn

See if there’s any output you’re getting, maybe I missed something. I edited my other post, could also need to move it continually if something is blocking it.

theres no errors in output so it cannot be any error, i think i will try to rescript it and if it works ima let you know

yea i think it was because of the pivotting i just moved the zombies from repStorage to the zombie’s spawn location, thanks anyways!

Pretty sure MoveToFinished fires after 8 seconds regardless of whether or not it’s completed. So you’d have to call MoveTo everytime it failed

local success = humanoid.MoveToFinished:Wait()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.