This code worked while I was testing pathfinding before although has seemed to stop working, I have the NPC unanchored, and everything is printing correctly. When I go in test mode it will print success although it hasn’t even moved yet.
local Pathfindingservice = game:GetService("PathfindingService")
local humanoid = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("UpperTorso")
local Ready = script.Parent:WaitForChild("Ready")
Ready.Changed:Connect(function()
if Ready.Value == true then
local line = workspace.Tills.Line.Q4.Occupied.Value == false
wait()
local PossibleTill = workspace.Tills.Points.Possible:GetChildren()
local ChosenTill = PossibleTill[math.random(1,#PossibleTill)]
print(ChosenTill.Name)
ChosenTill.Occupied.Value = true
print("Line 9")
local path = Pathfindingservice:CreatePath()
path:ComputeAsync(torso.Position, ChosenTill.Position)
local waypoints = path:GetWaypoints()
print("Line 23")
if path.Status == Enum.PathStatus.Success then
print("Success")
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:wait(2)
end
end
end
end
end)
Are there any solutions which may help? The ChosenTill is a part inside the folder which is randomised everytime. And that also prints fine.