I am trying to make a script that moves an NPC to an ore specifically the last ore in the table.
I tried printing in between lines and it seemed to stop working at the for loop. I have tried searching around the Developer Forum for an answer. But couldn’t find one that worked. I have tried to changing the position in case the path was blocked by anything but that didn’t work either.
local availableOre = oreTable[#oreTable] local PathfindingService = game:GetService("PathfindingService") local path = PathfindingService:CreatePath() local waypoints = path:GetWaypoints() function moveToOre() local worker = availableWorkers[#availableWorkers] for i, waypoint in pairs(waypoints) do if waypoint.Action == Enum.PathWaypointAction.Jump then worker.humanoid:ChangeState(Enum.HumanoidStateType.Jumping) end worker.Humanoid:MoveTo(availableOre.Position + Vector3.new(0,0,-1)) worker.Humanoid.MoveToFinished:Wait() end end if availableWorkers[#availableWorkers] and oreTable[#oreTable] == nil then repeat wait() until availableWorkers and oreTable[#oreTable] ~= nil moveToOre() else moveToOre()