Moveto finishing way too early

Let’s get straight into the point.

I want to make this NPC move to the desired part, but before reaching the part, it stopped already? the WalkSpeed is 2. this might be the reason, but how will I fix it?

here’s the script.

enemy.Humanoid:MoveTo(finish.Position)
enemy.Humanoid.MoveToFinished:Wait()

the NPC just stops after a few seconds.
When the WalkSpeed is 16, everything works fine.

1 Like

Do you have a video of this? It could be colliding with something which is forcing it to stop?

Try this out, does it always successfully print?

enemy.Humanoid:MoveTo(finish.Position)
local clock = os.clock()

enemy.Humanoid.MoveToFinished:Connect(function()
	warn("HUMANOID HAS SUCCESSFULLY REACHED THE PATH IN " .. os.clock() - clock .. " SECONDS!")
end)

MoveTo() has a timeout of 8 seconds. Irrespective of whether or not the humanoid reaches its intended destination its MoveToFinished signal is fired. Fortunately this signal returns a Boolean value indicating if or not the goal was reached.

https://developer.roblox.com/en-us/api-reference/event/Humanoid/MoveToFinished

4 Likes

Nope, when the NPC is at walkspeed 16, he walks to the desired point just fine.

I mean it does print that the NPC successfully reached the Point in 8 seconds. Is there a way to extend it more than 8 seconds?

Look at Forummer’s link. The example code at the bottom of the page shows how to do that.

Okay, I’ve found a way to Move it with no timeout thanks to this devforum post. Thank you everyone who has helped.

1 Like

oh, hey i had this issue too, Maybe this function can help you

local function moveTo(humanoid, targetPoint)
	local targetReached = false

	local connection
	connection = humanoid.MoveToFinished:Connect(function(reached)
		if humanoid.Parent.HumanoidRootPart.Anchored == false and humanoid.WalkSpeed ~= 0 then
			targetReached = true
			connection:Disconnect()
			connection = nil

			print("Finished moving")
		else
			moveTo(humanoid, targetPoint)
		end
	end)
	
	humanoid:MoveTo(targetPoint)

	spawn(function()
		while not targetReached do
			if not (humanoid and humanoid.Parent) then
				break
			end

			if humanoid.WalkToPoint ~= targetPoint then
				break
			end

			humanoid:MoveTo(targetPoint)
			task.wait(6)
		end

		if connection then
			connection:Disconnect()
			connection = nil
		end
	end)
end

I found this a long time ago, just customized by a bit