NOTE: please read post fully, i saw so much replies on the similiar topics where people have same problem as me, and people who was trying to help didn’t read topics fully and though people had problem with 8 sec timeout, i DONOT have 8 seconds timeout problem, i have problem that my mobs are reaching waypoints, but a little bit early, and i want them to reach the CENTER of waypoints, not just come close to them.
There’s function that removes timeout:
function MoveNPC(Point, Character)
--local HRP = Character.HumanoidRootPart
--local H = Character.Humanoid
repeat
wait()
if Character ~= nil then
if Character:FindFirstChild("HumanoidRootPart") then
if Character:FindFirstChild("Humanoid") then
Character.Humanoid:MoveTo(Point)
else
break
end
else
break
end
else
break
end
until (Character:FindFirstChild("HumanoidRootPart").Position - Vector3.new(Point.X, Character:FindFirstChild("HumanoidRootPart").Position.Y, Point.Z) ).magnitude <= 1
end
Can anybody please help me make mobs reach the center of the waypoints??? It’s a little problem but it really annoys me! I think it will annoy some players too.
Your magnitude check only has a threshold of one. To make it stop when it’s closer just make the threshold lower.
Code:
function MoveNPC(Point, Character)
local HRP = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if not HRP or not Humanoid then
return
end
while (HRP.Position - Vector3.new(Point.X, HRP.Position.Y, Point.Z)).Magnitude <= 0.2 do
Humanoid:MoveTo(Point)
task.wait()
end
end
Still they don’t move, i think it’s beacuse “while” works only when mob is close, but mob is not. To make it move we need to check until it close, not while it close. I’ll try to change < to >
Edit: they walk, but as i said if it less than 0.7 they just stop at the first waypoint.
Could you use this? It’s just a loop but checks if the path is finished using :MoveToFinished.
Code:
function MoveNPC(Point, Character)
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if not Humanoid then
return
end
local targetReached = false
local connection
connection = Humanoid.MoveToFinished:Connect(function()
targetReached = true
connection:Disconnect()
end)
repeat
Humanoid:MoveTo(Point)
task.wait(6)
until targetReached
end
for d=1, #workspace.Canyon.Waypoints:GetChildren() do
MoveNPC(workspace.Canyon.Waypoints:FindFirstChild(d).Position, mob)
end
Edit: your script worked, mobs just started moving after 6 seconds, but mobs moves at the next waypoint only after 6 seconds, i just used task.wait() and it still ends a little bit early. And also it causing a little lag
I made better optimized MoveNPC function, beacuse so much zombies were making a lag. Why? Simple, game was running :MoveTo() so much, and that was making a lag. Now it runs it only when MoveToFinished, and checks if zombie is got to the end, if not - he go to the point again.
Thanks for answering! I already found a way, humanoids causing a big lag so i used tween and it doesn’t have that problem, but i’ll try that way with humanoids (so if i will need to use humanoids i will know how to fix that problem), and if it will help - i will make you know!
I already using bezier curve to achieve that effect, but that looks better tho! Thanks for replying, i’ll try that method to make better and easier turns. (for now i using 3 parts on every turn and do bezier curve on them)