Hey, I made an enemy movement script for my TD game, but I hate the MoveTo timeout so I searched up how to counter the timeout, I found this post and followed it
But It doesn’t work, the error was at line 10 (I’m not good at explaining so)
Edit: It’s a module script
Script:
function Enemies.MoveToExit(ConfirmedEnemies)
local EnemyInfo = ConfirmedEnemies.Information
for Point = 1, #workspace.Map.Points:GetChildren() do
local HRP = ConfirmedEnemies.HumanoidRootPart
repeat
wait()
ConfirmedEnemies.Humanoid:MoveTo(Point)
until (HRP.Position - Vector3.new(Point.X, HRP.Position.Y, Point.Z) ).magnitude <= 1
end
end
Point is a double, not a Vector3. This should fix it:
function Enemies.MoveToExit(ConfirmedEnemies)
local EnemyInfo = ConfirmedEnemies.Information
for _, Point in workspace.Map.Points:GetChildren() do
local HRP = ConfirmedEnemies.HumanoidRootPart
repeat
task.wait()
ConfirmedEnemies.Humanoid:MoveTo(Point.Position)
until (HRP.Position - Vector3.new(Point.Position.X, HRP.Position.Y, Point.Position.Z) ).magnitude <= 1
end
end
local Points = workspace.Map.Points
for Index = 1, #Points:GetChildren() do
local Point = Points:FindFirstChild(Index)
if not Point then continue end
local HRP = ConfirmedEnemies.HumanoidRootPart
repeat
task.wait()
ConfirmedEnemies.Humanoid:MoveTo(Point.Position)
until (HRP.Position - Vector3.new(Point.Position.X, HRP.Position.Y, Point.Position.Z) ).magnitude <= 1
end