Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why pathfinding doesnt work when script started from another script?

Asked by 1 year ago
Edited 1 year ago

Hi, im pretty new to scripting and i ran into this problem. So when I have disabled script and enable it in proporties the pathfinding works and npc is avoiding obstacles, but when i enable same script from another script by using script.Disabled it is going straight to destonation. I aslo tried doing something with if or repeat until but non of these work. Can sombody help? That's script inside of npc. (btw. sorry for my English)

local PS = game:GetService("PathfindingService")

local human = script.Parent.Humanoid
local Torso = script.Parent.Torso


local path = PS:CreatePath()
path:ComputeAsync(Torso.Position, game.Workspace.EatingPart.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
    if waypoint.Action == Enum.PathWaypointAction.Jump then
        human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
end

human:MoveTo(game.Workspace.EatingPart.Position)

And its disabled from beginging but enabled from other script.

0
If your trying to turn it on from a local script then it won't run because it's locally! MattVSNNL 620 — 1y

Answer this question