This is my code for my NPC Boss to move to where the player is but no errors show up in the output and the NPC doesn't move even though it's getting a position to go to. Help? Edit: Some variables were named wrong. Still doesn't move though.
local function moveToTarget(target)
if not target then return end
newPath:ComputeAsync(Torso.Position, target.Torso.Position)
waypoints = {}
if newPath.Status ~= Enum.PathStatus.Success then
bossHumanoid:MoveTo(Torso.Position)
return
end
waypoints = newPath:GetWaypoints()
pathIndex = 1
bossHumanoid:MoveTo(waypoints[pathIndex].Position)
PlayAnimations(2, Enum.AnimationPriority.Movement)
idlingAnim:Stop()
local connection
connection = bossHumanoid.MoveToFinished:Connect(function(reached)
if reached then
if target.Torso.Position == waypoints[#waypoints].Position then
if pathIndex < #waypoints then
pathIndex = pathIndex + 1
bossHumanoid:MoveTo(waypoints[pathIndex].Position)
end
else
newPath:ComputeAsync(Torso.Position, target.Torso.Position)
waypoints = newPath:GetWaypoints()
pathIndex = 1
bossHumanoid:MoveTo(waypoints[pathIndex].Position)
end
end
connection:Disconnect()
end)
local blockConnection
blockConnection = newPath.Blocked:Connect(function(blockedIndex)
if blockedIndex >= pathIndex then
newPath:ComputeAsync(Torso.Position, target.Torso.Position)
waypoints = newPath:GetWaypoints()
pathIndex = 1
bossHumanoid:MoveTo(waypoints[pathIndex].Position)
end
blockConnection:Disconnect()
end)
if blockConnection then
blockConnection:Disconnect()
end
if connection then
connection:Disconnect()
end
end

2 comments
It is unanchored and I tested MoveTo() in the script and it moves regularly in a straight line
but won't work from some reason when i try to make it move to one of the points in the path