Hello, i want to make a new tower defense game without a kit. but I found this problem…
Any ideas on how to fix it?.
this is the scripts.
function enemy.Move(Enemy)
local Humanoid = Enemy:WaitForChild("Humanoid")
local path = Pathfindingservice:CreatePath()
for i = 1, #MapPath:GetChildren() do
if i == #MapPath:GetChildren() then
Enemy:Destroy()
Map:WaitForChild("EnemyCount").Value -= 1
break
end
local Finished = false
Humanoid:MoveTo(MapPath[i + 1].Node.WorldPosition)
print(Enemy.Name, "is moving to ", i + 1)
Humanoid.MoveToFinished:Wait()
print(Enemy.Name, "Move finished.")
end
end
Its because of pathfinding service. Since it’s trying to get the fastest path. I’d recommend you make a folder and add waypoints so at the end of each corner, add a part and name it 1-2-3 etc. Then type this into a script:
for i,v in pairs(folderhere) do
humanoid:MoveTo(v.Position)
humanoid.MoveToFinished:Wait()
end
If :MoveTo() takes too long it will automatically be set to finished, because the game thinks the npc is stuck. The noobs with the golden heads move slowly and it might be why they’re skipping some nodes.
You could also repeat MoveTo() until the distance between the character and the node is less then 4 studs or smaller. Humanoid:MoveTo (roblox.com) also has a solution on how to remove the timeout.
Why dont u use tweenservice for td path. its the best way to do the enemy movements. im currently working on a td game too and mine works perfectly with the tweens