Pathfinding isnt making wayponts

I was trying to make a simple pathfinding script but it wasnt making waypoints. Eventually I tried it in a different game with the exact same script and it worked. Nothing is interfering with the script in the first game.
Here is the script that was pretty much the exact same in each game:

local pathfindService = game:GetService("PathfindingService")
local path = pathfindService:CreatePath()
local npc  =script.Parent
local goal = script.Parent.Parent.Part
local humanoid = npc.Humanoid
path:ComputeAsync(npc.HumanoidRootPart.Position,goal.Position)
local waypoints = path:GetWaypoints()

for _, waypoint in pairs(waypoints) do
	humanoid:MoveTo(waypoint.Position)
	humanoid.MoveToFinished:Wait()
end

Are there any errors? could be because you’re running it as soon as the game is run

There are no errors with the one that doesn’t work