local PathfindingService = game:GetService("PathfindingService") local ship = script.Parent.Parent.Parent local humanoid = ship.Humanoid local goal = script.Parent local path = PathfindingService:CreatePath() local waypoints local currentWaypointIndex local showpoints = false --if true shows the waypoints. local waypointcontainer = Instance.new("Model") local cleanpoints = false function FollowPath(goal) path:ComputeAsync(ship.HumanoidRootPart.Position, goal.Value) waypoints = {} if path.Status == Enum.PathStatus.Success then waypoints = path:GetWaypoints() currentWaypointIndex = 1 humanoid:MoveTo(waypoints[currentWaypointIndex].Position) else humanoid:MoveTo(ship.HumanoidRootPart.Position) cleanpoints = true end end function onWaypointReached(reached) if reached and currentWaypointIndex < #waypoints then currentWaypointIndex = currentWaypointIndex + 1 humanoid:MoveTo(waypoints[currentWaypointIndex].Position) elseif reached and waypointcontainer and currentWaypointIndex == #waypoints then cleanpoints = true end end function showwaypoints() spawn(function() waypointcontainer.Parent = game.Workspace local waypoints = path:GetWaypoints() for _, waypoint in pairs(waypoints) do local part = Instance.new("Part") part.Shape = "Ball" part.Material = "Neon" part.Size = Vector3.new(0.6, 0.6, 0.6) part.Position = waypoint.Position part.Anchored = true part.CanCollide = false part.Parent = waypointcontainer end repeat wait() until cleanpoints == true if cleanpoints == true then waypointcontainer:Destroy() cleanpoints = false waypointcontainer = Instance.new("Model") end end) end humanoid.MoveToFinished:Connect(onWaypointReached) script.Parent.Changed:Connect(function() if script.Parent.Value ~= Vector3.new(0,0,0) then FollowPath(goal) if showpoints == true then showwaypoints() end end end)
(I apologize if the script above is long, but I needed to include all the functions so my problem can be better understood)
this is my pathfinding script. and it works fine except for one problem. instead of going around other humanoids it attempts to go through them as if they dont exist. this is a problem because the npc is a ship following a waypoint, and the planets around it have humanoids in them. and while one option is to make them all cancollide false, this is also not possible because if the ship touches the planet it will attempt to land in it. is there a way I can get the npc to treat other humanoids like any other blocking barrier?