Hello, at the moment my pathfinding NPCs appear to be really jolty and i don't believe it is to do with server lag because when i fire my gun the projectile is moving at a good speed. So i believe it is to do with the path the NPCs are following. Anyone know how i would fix this?
local head = script.Parent.Parent:FindFirstChild("Head")
while true do
local PathfindingService = game:GetService("PathfindingService")
local NPC = script.Parent.Parent
local Humanoid = NPC.Humanoid
local RootPart = NPC.HumanoidRootPart
local Target = workspace.NoirPhoenix:FindFirstChild("HumanoidRootPart")
local Start = RootPart.Position
local Goal = Vector3.new(Target.Position.X -7,Target.Position.Y, Target.Position.Z)
local path = PathfindingService:FindPathAsync(Start, Goal)
local waypoints = path:GetWaypoints()
for waypointIndex, waypoint in pairs(waypoints) do
local waypointPosition = waypoint.Position
if waypointPosition.Y >= head.Position.Y then
print("Jump")
Humanoid.Jump = true
end
Humanoid:MoveTo(waypointPosition)
Humanoid.MoveToFinished:Wait()
end
wait()
end

3 comments
If you are using :Wait() for MoveToFinished, try give the NPC network ownership to the server.
and how do i do that?
Don't create all of your variables inside the while loop. Only put inside the loop what is being looped, otherwise you're creating the same variables probably over thousands of times.