I have tried different rigs and even made a script inside the NPC, same issue. Not sure why it is doing the same thing anyways I try and I have spent hours looking for solutions, with no luck. I am trying to get the NPC to walk to a part, located in the “NPCWalkPoints”.
This is all the NPC does.
As you can see, the 3 neons parts are the waypoints, but the NPC isn’t going anywhere near those.
This is the script (not entirely, just what has something to do with the NPC)
local _Workspace = game:GetService("Workspace")
local PathfindingService = game:GetService("PathfindingService")
local MainNPCGuard = _Workspace:WaitForChild("TheMovingGuard")
local NPCWalkPoints = _Workspace:WaitForChild("NPCWalkPoints")
function showPath(path)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
local part = Instance.new("Part", _Workspace.stuff)
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = waypoint.Position
game:GetService("Debris"):AddItem(part, 5)
end
end
function createPath(target)
local agentParams = {
AgentHeight = 2.5,
AgentRadius = 3,
AgentCanJump = false
}
local path = PathfindingService:CreatePath(agentParams)
path:ComputeAsync(MainNPCGuard.HumanoidRootPart.Position, target.Position)
print(target.Position)
print("path computed")
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
print("waypoints created")
return path, waypoints
end
end
function mainNPCMove(target)
local PathNPCHum = MainNPCGuard:WaitForChild("Humanoid")
print(target)
print(target.Position)
if target then
print("target found")
local path, waypoints = createPath(target)
if path and waypoints then
local showThePath = showPath(path)
print("path and waypoints exist")
for _, towaypoint in pairs(waypoints) do
if towaypoint.Action == Enum.PathWaypointAction.Jump then
PathNPCHum:ChangeState(Enum.HumanoidStateType.Jumping)
end
PathNPCHum:Move(towaypoint.Position)
print("moving")
PathNPCHum.MoveToFinished:Wait()
print("moving finished")
end
end
end
end
mainNPCMove(NPCWalkPoints.CellsPartBlast)
I am not sure what I am doing wrong, everything prints as it intends to.