Help on making Enemies Go Around a Map by alkpoints

Hello, I am currently working on a quick small system of making NPC’s going around a map by using walkpoints and Humanoid MoveTo Function, I need help on this I could only make them go to the first walkpoint but I am struggling on making them detect if they touched a walkpoint so they could go to the other checkpoint, what am I doing wrong and how could I solve it? (The Script is inside the NPC’s they get disabled when cloned, this connects to my last post)

I’ve been trying to do this for One Hour now and heres the final edit I’ve made to the Script.

local Runner = script.Parent
local Humanoid = Runner:WaitForChild("Humanoid")
local walkpoints = script.Parent.Parent.Parent.walkpoints

Humanoid:MoveTo(walkpoints.Point_1.Position)
for i, v in pairs(Runner:GetChildren()) do
	v.Touched:Connect(function(Hit)
		if Hit.Name == "Point_1" then
			Humanoid:MoveTo(walkpoints.Point_2.Position)
		end
	end)
end


heres a photo of the walkpoints and map

Humanoid.MoveToFinished:(SomePositionhere?)
-- i remember when i was playing around

--with this thing, i don't know if will help

--if somehow don't work then try 
Humanoid.MoveToFinished:Wait(3) -- Time here

what i can say is, when the humanoid reach the point, (MoveToFinished will work) and he will wait a few seconds before moving to the next position

Could you explain more about this please, like how and when am I suppose to use it.

Could you explain more about this please, like how and when am I suppose to use it.
I am just a bit confused sorry.

for example:

local Runner = script.Parent
local Humanoid = Runner:WaitForChild("Humanoid")
local walkpoints = script.Parent.Parent.Parent.walkpoints

Humanoid:MoveTo(walkpoints.Point_1.Position)

Humanoid:MoveToFinished:Wait(1) -- after one second, he will move to the next
--waypoint, or somewhere you marked as a "reference"

Humanoid:MoveTo(Point_2.Position)
Humanoid:MoveToFinished:Wait(1) 

Humanoid:MoveTo(Point_3.Position)
Humanoid:MoveToFinished:Wait(1)

--and etc, some people will say that this is spam xd but atleast works


and remove the other code below
you don't need to do a loop to move humanoid, if you specify their tasks
they will just follow orders to move to positions, you don't need to do anything else
1 Like

Thanks, and I might find a way of making this Code Smaller soon maybe by For I, V Pairs if possible.

because MoveToFinished will check when the humanoid reached the Waypoint

and after some time "like i said, the Wait in the end, he will wait some time before
moving again.

if you don’t want them to wait, just
Humanoid.MoveToFinished:Wait() – will wait until they reach the Waypoint and
will move instantly

local Runner = script.Parent
local Humanoid = Runner:WaitForChild("Humanoid")
local walkpoints = script.Parent.Parent.Parent.walkpoints
pathes = workspace.(....)





for i, v in pairs(pathes:GetChildren()) do
	Humanoid:MoveTo(v.Position)
    Humanoid:MoveToFinished:Wait()
end

and if you want to make tower defense, better use tween. Because MoveTo has a lot of bad such time out and other things.

I have been Wanting to make a toWer defense game for months noW, because of tds mostly and i am planning to make one after i make smaller projects and practice more on scripting because even rn a small toWer defense game is to big for me.