You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
the code im using is not working at all
What is the issue? Include screenshots / videos if possible!
its giving me a warning in the output ( yes i did do that)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
heres my code:
i tried looking on the developer forums but found nothing that could fix my issue
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local pfs = game:GetService("PathfindingService")
script.Parent.AncestryChanged:Connect(function()
if (script.Parent.Parent.Name == "Mobs") then
local player = game:GetService("Players"):FindFirstChild(script.Parent.Parent.Parent.Owner.Value)
if (player) then
local base = workspace.Bases[player.Base.Value]
local path:Path = pfs:CreatePath()
path:ComputeAsync(script.Parent.HumanoidRootPart.Position,base["Village Hall"].PrimaryPart.Position)
if(path.Status == Enum.PathStatus.Success) then
for index,wp in pairs(path:GetWaypoints()) do
script.Parent.Humanoid:MoveTo(wp.Position)
script.Parent.Humanoid.MoveToFinished:Wait()
local point = Instance.new("Part")
point.Material = Enum.Material.Neon
point.Position = wp.Position
point.Anchored = true
point.CanCollide = false
point.Parent = workspace
if (wp.Action == Enum.PathWaypointAction.Jump) then
script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end
elseif (path.Status == Enum.PathStatus.NoPath) then
warn("could not compute path!")
end
end
end
end)
thanks for reading. if you can help me then please do it.
I also added a few parts on the waypoints position to know where its going
It’s not showing because it’s not traversable. The Humanoid cannot just go anywhere you want it to go unless walking/jumping to that position is possible.
walking and jumping to that place is possible, even for a player. the goal is blocked by a wall, but you can still reach your destination. i see no reason pathfinding is not possible
You can very well reach the goal using your character but there are certain limitations to Roblox’s PathfindingService which prevent the Humanoid from reaching the goal even if you are able to. The only solution to your problem is either to create a custom pathfinding algorithm instead of using PathfindingService or if you want to keep using PathfindingService, make sure you move your parts so that all of them are connected by arrows.
thanks ill try it. but making a pathfinding algorithm is quite hard. ill assume youll have to make a while loop, then check if pathfinding is possible using raycasting or use a for loop that loops through the entire game and spawns a few parts and check which is the best path possible.
Only if the normal roblox player can jump to that position, then npc can jump, however by default npc cannot jump high, you need to edit the settings of path finding when finding path to detect blocks higher, however npc cannot jump higher than normal player if you keep the humanoid setting as low jump power