Hi, My non-humanoid Npc pauses at a waypoint each time it reaches it. Is there a way to fix this?
Code:
for i,v in pairs(waypoints) do
if i ~= 1 then
local distance = (waypoints[i - 1].Position - v.Position).Magnitude
local tweenInfo = TweenInfo.new(distance/self.walkspeed)
self.Npc.PrimaryPart.CFrame = CFrame.lookAt(self.Npc.PrimaryPart.Position,Vector3.new(v.Position.X,self.Npc.PrimaryPart.Position.Y,v.Position.Z))
tween = TweenService:Create(self.Npc.PrimaryPart,tweenInfo,{Position = v.Position + Vector3.new(0,self.Npc.PrimaryPart.Size.Y/2)})
tween:Play()
tween.Completed:Wait()
end
end
This is using pathfinding service; when it reaches a waypoint it pauses for a little bit. It might be hard to see because of the laggy video, but there are multiple waypoints.