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
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
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
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.