so ive been working on this all day and basically my npc stutters or lags when it moves. it like freezes for a half a second pretty often
its supposed to follow the player even when they move
local function getpathfindingpath(entity, nearestplr) local entityPath = pathFindingService:FindPathAsync(entity.PrimaryPart.Position, nearestplr.PrimaryPart.Position) local waypoints = entityPath:GetWaypoints() return waypoints[2] end wait(5) local function getwaypoints(v) local nearestplr = game.Players:WaitForChild('thenormalelevator3').Character local waypoint = getpathfindingpath(v, nearestplr) return {waypoint, nearestplr} end for q,w in pairs(entity:GetChildren()) do if w:IsA('BasePart') then w:SetNetworkOwner(nil) end end runservice.Heartbeat:Connect(function() local waypoints = getwaypoints(entity) local v = waypoints[1] if v ~= nil then local pos = v.Position entity.Humanoid:MoveTo(pos) end end)
here's my code