My NPC moving incorrectly?

I made an NPC “:MoveTo” script…

local Dummy = script.Parent.Humanoid

local Part1 = game.Workspace:WaitForChild(“GrassIsles”).Part1

local Part2 = game.Workspace:WaitForChild(“GrassIsles”).Part2

local Part3 = game.Workspace:WaitForChild(“GrassIsles”).Part3

local Part4 = game.Workspace:WaitForChild(“GrassIsles”).Part4

local Part5 = game.Workspace:WaitForChild(“GrassIsles”).Part5

local Part6 = game.Workspace:WaitForChild(“GrassIsles”).Part6

local Part7 = game.Workspace:WaitForChild(“GrassIsles”).Part7

wait(5)

script.Parent.Head.Transparency = 0
script.Parent[“Left Arm”].Transparency = 0
script.Parent[“Left Leg”].Transparency = 0
script.Parent[“Right Arm”].Transparency = 0
script.Parent[“Right Leg”].Transparency = 0
script.Parent.Torso.Transparency = 0

Dummy:MoveTo(Part1.Position)
Dummy.MoveToFinished:Wait()
Dummy:MoveTo(Part2.Position)

What The Dummy does:

Please Help!

There isn’t really much explaining what is going on in this post, you can’t just drop your code and wait for someone to give you code that will work. Could you please tell us what the Dummy is suppose to do and what it is doing? It is also hard to tell from the image what is going on, a little video clip would have been better. If you can let us know these few things I and I’m sure others would be happy to help!

One thing I do see in your code though is it looks a little repetitive, I recommend using for loops (specifically ipairs) to shorten down your code and make it easier not only for others to read, but for you as well. It can really help shorten down your code and help you find ways to fix your code.

I am trying to make the NPC walk down the track and cause damage but it walks into the invisible wall (That prevents players ruining its movement). I tried to toggle the Part1 and Part2 Positions but no difference.

Humanoid MoveTo Without Time out

“This code sample includes a function that avoids the 8 second timeout on Humanoid:MoveTo by calling Humanoid:MoveTo again before the timeout elapses. It also includes an optional andThen parameter where developers can pass a function to be called when the humanoid reaches its destination.”

What they are saying is after 8 seconds Humanoid:MoveTo() will be cancelled and Dummy.MoveToFinished will be called.

To fix this you would need to repeatedly call Humanoid:MoveTo() with this function:

local function moveTo(humanoid, targetPoint, andThen)
	local targetReached = false
 
	-- listen for the humanoid reaching its target
	local connection
	connection = humanoid.MoveToFinished:Connect(function(reached)
		targetReached = true
		connection:Disconnect()
		connection = nil
		if andThen then
			andThen()
		end
	end)
 
	-- start walking
	humanoid:MoveTo(targetPoint)
 
	-- execute on a new thread so as to not yield function
	spawn(function()
		while not targetReached do
			-- does the humanoid still exist?
			if not (humanoid and humanoid.Parent) then
				break
			end
			-- has the target changed?
			if humanoid.WalkToPoint ~= targetPoint then
				break
			end
			-- refresh the timeout
			humanoid:MoveTo(targetPoint)
			wait(6)
		end
		
		-- disconnect the connection if it is still connected
		if connection then
			connection:Disconnect()
			connection = nil
		end
	end)
end

Please read more here:

Just Fixed it, nothing wrong with the script. It was the track.