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.

2 comments

0

If your trying to turn it on from a local script then it won't run because it's locally!