Could you send the entire script so I can have a better idea of what the issue could be?
And if possible, tell me if it is a LocalScript or a ServerScript.
Server script, entire code:
I hope it is not confusing!!
function MoveNpc(npc,destination,canSit,errored)
print("triggered")
-- if DangerZone then
-- path.Costs = {DangerZone}
-- end
--DangerZone = nil
local anchoreo = npc.HumanoidRootPart.Anchored
npc.HumanoidRootPart.Anchored = false
local time = tick()
if errored == true then
print("second program activated.")
return;
end
if canSit == true then
CanSitAmelieCafe.Value = true
else
CanSitAmelieCafe.Value = false
end
local human = npc.Humanoid
local s,e = pcall(function()
path:ComputeAsync(npc.HumanoidRootPart.Position,destination.Position)
end)
if not s then
print("ERROR WITHIN COMPUTING:",e)
return
else
print(s)
end
if npc:FindFirstChildWhichIsA("WeldConstraint") then
npc.WeldConstraint.Enabled = false
print("disabled")
end
local Waypoints = path:GetWaypoints()
warn("AHAAAAAAAAAAAAAA",#Waypoints)
local distance
curnp = npc
cursi = canSit
curer = errored
for _,point in pairs(Waypoints) do
print("pong")
curdes = destination
curwp += 1
if point.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
print("is the dam npc even moving and not tping right away???")
human:MoveTo(point.Position)
local finish = false
local connection
connection = human.MoveToFinished:Connect(function(reached)
--print("finished.",reached)
finish = true
connection:Disconnect()
end)
repeat
distance = (point.Position - npc.PrimaryPart.Position).Magnitude
if finish then break end
task.wait()
until distance <= 5 or finish == true
connection:Disconnect()
end
task.wait()
if canSit == true then
pcall(function()
workspace.Tables.AmelieTable.AmelieSeat.Seat:Sit(workspace.AmeliEcafe.Humanoid)
end)
--CheckIfSat(npc,destination)
end
npc.HumanoidRootPart.Anchored = anchoreo
end
Just to know, is the “destination” an Instance or a Vector3?
I’m assuming it is an Instance judging by the code.
Also, can I assume you just did not include a path instance in the script you sent here? 'Cause I couldn’t find any variable in the code that directly referenced a path.
@tusart I focused on this section of your code, and I kid you not I got it working first try which is quite confusing… (And I didn’t even edit it at all…)
Max I did was creating a path so I could have a reference instance and setting up an NPC + destination.
local path=game:GetService("PathfindingService"):CreatePath()
local npc=workspace.Dummy
local destination=workspace.Part
local s,e = pcall(function()
path:ComputeAsync(npc.HumanoidRootPart.Position,destination.Position)
end)
if not s then
print("ERROR WITHIN COMPUTING:",e)
return
else
print(s)
end
if npc:FindFirstChildWhichIsA("WeldConstraint") then
npc.WeldConstraint.Enabled = false
print("disabled")
end
local Waypoints = path:GetWaypoints()
warn(#Waypoints)
No clue what happened on your end, but clearly this section is not faulty.
Do you think the problem can be when I have the path attached to a blockedPath function? I will try to experiment more and do further research, then let you know. In case you get any more info, I am here anytime.
Forgot to let you know that my game has a lot of parts making it very laggy, I had to set streaming enabled on to a radius of 100 to get better performance, BUT the NPC won’t walk even if streaming enabled is off.
@tusart bruh this code is a whole nother level that i even gave up from acting formally
(also i dont mean this in a mean way, the code itself is fine, its just that i was surprised to see there was actually no issues going on)
local path=game:GetService("PathfindingService"):CreatePath()
local npc=workspace.Dummy
local destination=workspace.Part
local errored=false
local canSit=false
local anchoreo = npc.HumanoidRootPart.Anchored
npc.HumanoidRootPart.Anchored = false
local time = tick()
if errored == true then
print("second program activated.")
return;
end
local human = npc.Humanoid
local s,e = pcall(function()
path:ComputeAsync(npc.HumanoidRootPart.Position,destination.Position)
end)
if not s then
print("ERROR WITHIN COMPUTING:",e)
return
else
print(s)
end
if npc:FindFirstChildWhichIsA("WeldConstraint") then
npc.WeldConstraint.Enabled = false
print("disabled")
end
local Waypoints = path:GetWaypoints()
warn("AHAAAAAAAAAAAAAA",#Waypoints)
local distance
curnp = npc
cursi = canSit
curer = errored
curwp = 0
for _,point in pairs(Waypoints) do
print("pong")
curdes = destination
curwp += 1
if point.Action == Enum.PathWaypointAction.Jump then
human:ChangeState(Enum.HumanoidStateType.Jumping)
end
print("is the dam npc even moving and not tping right away???")
human:MoveTo(point.Position)
local finish = false
local connection
connection = human.MoveToFinished:Connect(function(reached)
--print("finished.",reached)
finish = true
connection:Disconnect()
end)
repeat
distance = (point.Position - npc.PrimaryPart.Position).Magnitude
if finish then break end
task.wait()
until distance <= 5 or finish == true
connection:Disconnect()
end
task.wait()
npc.HumanoidRootPart.Anchored = anchoreo
WELL, safe to assume it is indeed the blockedPath function since all I did to test the code out this time was just removing the seating stuff. :’)
@Zoiudolo Good news. The problem was finally fixed after even further research ( I am confusingly satisfied by how I found the post when I could find it before).
The problem was that in the workspace, there was Humanoid. Just that managed to break the whole pathfinding system, but now it is working well! I want to thank you for your time spent helping me as it definitely helped me move further.