Hello, current I have a script to move my enemy, but it is not efficient. It bugs out sometimes and I wanna see if there is a more better way of doing it, either by tween service or pivot. Can somebody help on how to make it more efficient?
function mob.Move(mob, map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint =1, #waypoints:GetChildren() do
mob.MovingTo.Value = waypoint
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
if humanoid.Health > 0 then
HPInt.Value -= humanoid.Health
end
mob:Destroy()
end
By more efficient I mean that the code bugs a lot and is not smooth, like the enemy does not follow the path sometimes and goes off of it thats why I wanna learn how to maybe implement tween or piviot to this.