How to PATHFIND in Roblox 2024 using Forbidden

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 มี.ค. 2023
  • #robloxdev #robloxcode #roblox #robloxdeveloper #roblox #pathfinding
    Link to API: www.roblox.com/library/112294...
    new create web link: create.roblox.com/store/asset...
    This is how you use Forbidden to make a pathfinding system in your game to save 3 WEEKS of coding with one line of code.
    Please comment with your game's name/link if you use Forbidden and good luck!
    Discord: / discord
    TIME STAMPS
    1:07 Inserting into game
    1:31 Info on Forbidden
    3:10 Inserting NPC
    3:27 Start of Code
    4:28 Track Player Code (basic)
    #robloxstudio
    #npc
    #robloxdev
    #pathfinding
    #forbidden
  • เกม

ความคิดเห็น • 264

  • @CritDEV
    @CritDEV  ปีที่แล้ว +12

    Link to API
    www.roblox.com/library/11229474803/Forbidden-API-OFFICIAL
    Common issues in replies.
    Enjoy making your game!

    • @ConeParty
      @ConeParty 10 หลายเดือนก่อน

      It is forbidden to unsubscribe to you

    • @HeroDevv
      @HeroDevv 7 หลายเดือนก่อน +1

      Hey, I am trying to make a game, I need an NPC that can complete advanced parkour courses (not extremely advanced, i just mean like at least be able to jump over a gap, which the default PathfindingService doesn't do.) Can this do jumps?

    • @CritDEV
      @CritDEV  7 หลายเดือนก่อน +1

      @@HeroDevv it uses the default pathfinding service, but only simplifies it

    • @YeaIDoStuff
      @YeaIDoStuff 5 หลายเดือนก่อน

      Fair warning id watch another video on Pathfinding Parameters because it helps with making the AI jump and doge certain blocks. (like kill bricks etc.) and plus the fact it is not covered here.

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน

      @@YeaIDoStuff Yes, i didn’t cover the standard settings. However when calling the API, in the settings table you can set those settings using the key [“StandardPathfindSettings”]

  • @hutcle
    @hutcle 6 หลายเดือนก่อน +2

    I’ve used this for my game and I just wanted to say a massive thanks I put this in my first devlog on my channel but didn’t shout u out but in my next vid I will because this was so helpful

  • @aspirin4279
    @aspirin4279 ปีที่แล้ว +38

    I came here by watching yt shorts

    • @zaydtruck3496
      @zaydtruck3496 8 หลายเดือนก่อน

      Same

    • @canadaboy461
      @canadaboy461 8 หลายเดือนก่อน

      Bawls same!

    • @EpicPico0625
      @EpicPico0625 7 หลายเดือนก่อน +1

      Sqme

    • @JPSCOMMENT
      @JPSCOMMENT 7 หลายเดือนก่อน

      Same

    • @chieloup
      @chieloup 7 หลายเดือนก่อน +1

      Same

  • @soundsofjupiter2859
    @soundsofjupiter2859 ปีที่แล้ว +5

    very cool lookin forward to updates

  • @turbs1348
    @turbs1348 6 หลายเดือนก่อน +2

    Homie I am your 500th sub, thank you for this btw its great.

  • @Sugar._.Stxrrr
    @Sugar._.Stxrrr 2 หลายเดือนก่อน +1

    This was so helpful tysm 😭

  • @patriot7260
    @patriot7260 6 หลายเดือนก่อน +5

    You are a life saver. Devs like you are heroes.

    • @maciezez
      @maciezez วันที่ผ่านมา

      I wouldnt say so he uses a kit basically everyone can do this

  • @CopyStudiosFilms
    @CopyStudiosFilms 8 หลายเดือนก่อน +2

    THIS MAN IS HEAVILY UNDERRATED!

  • @taywanjesuper5954
    @taywanjesuper5954 6 หลายเดือนก่อน

    Just waitin till u EXPLODE WITH SUBS brooo this is AHHMAZING!

  • @galvanygames1441
    @galvanygames1441 ปีที่แล้ว +1

    This is incredible, thank you friend, I will make the most of it.

    • @Daber-wh5ug
      @Daber-wh5ug 11 หลายเดือนก่อน

      How did you get it to work can you paste the code?

  • @Ismail_NotFullName
    @Ismail_NotFullName 6 หลายเดือนก่อน

    Alright so i just checked it out, the forbidden api also has some other really convenient stuff including the Ai stuff. Im talking math, datastoring, and some misc stuff. I really recommend you check it out if you just wanna make a game without dealing with annoying BS that would slow down the production of a pretty small game drastically.
    edit: the AI can be really janky. it does not like to jump, so much so that it would rather give up and stand in place instead of it. Be careful if you going to use it on a map with jumpable obstacles with multiple turns

  • @DomExists
    @DomExists 9 หลายเดือนก่อน +1

    When i have it set to go to a part it will move for a second then stop, if I make it follow me it only moves when I move, how do I fix this?

  • @Yuilix
    @Yuilix 22 วันที่ผ่านมา

    I'll see what i can do since im a beginner it'll be kinda difficult for me to add stuff like the extra things that i want im making a realistic shooter game to shoot zombies

  • @user-cw1ow1cv2f
    @user-cw1ow1cv2f 9 หลายเดือนก่อน +1

    I think u broke something in an update as im getting this error "Unable to assign property Value. Object expected, got PathWaypoint "

  • @Jagrio
    @Jagrio ปีที่แล้ว +1

    Had some trouble at first but here is the script I used that finally got it tracking if anybody else is having trouble

    • @Jagrio
      @Jagrio ปีที่แล้ว

      local rs = game:GetService("ReplicatedStorage")
      local forbidden = rs:WaitForChild("Forbidden")
      local ai = require(forbidden:WaitForChild("AI"))
      local NPC = script.Parent
      wait(2)
      wait(2)
      ai.SmartPathfind(NPC, game.Players:GetChildren()[1],true,{Visualize = true, Tracking = true})
      wait(10)
      ai.Stop(NPC)
      wait(1)
      ai.SmartPathfind(NPC, game.Players:GetChildren()[1], true, {Visualize = true, Tracking = true})

  • @lemonslice4507
    @lemonslice4507 ปีที่แล้ว +4

    hey dude if you can can it be possible for sight distance so it wanders around going around then when you get into its sight it chases you then stops after a while

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Use the apis line of sight function

  • @YoungBassAngler
    @YoungBassAngler 11 หลายเดือนก่อน +3

    Hey Critixx! I thank you so much for this script and it has saved me hours. I do have one question. Do you think you will be willing to help me make it so the ai will recognize what a door is and will have a function to open it and also play an animation? There is just so much to this path-finding complicated group of scripts that I don't understand. I don't know where to even start to add this function. If you don't want to help fine with me! You have done plenty! Love your content and keep it up!

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน +1

      Unfortunately that’s rather complicated since that would involve making your own pathfinding system.
      The way around it would most likely be to make the doors non-collidable on the server side (make sure the client is) and then whenever it touches the door check if it is open or do an animation (the ai will then consider it in the shortest path)
      Edit: as long as you are confident enough in your coding ability to be able to signal a stop in the ai as it approaches a door and then restart it once it is open you should be able to do this

    • @YoungBassAngler
      @YoungBassAngler 11 หลายเดือนก่อน

      Alright. Again, I really appreciate it
      @@CritDEV

    • @JJsStuff
      @JJsStuff 11 หลายเดือนก่อน +1

      @@YoungBassAngler Use raycast, and if in the ray it will detect if there is a part called "Door" if so it will proceed with a tween to open the door.

    • @Mikey91112
      @Mikey91112 7 หลายเดือนก่อน

      I think I have a solution for you... You can set the destination to the door, then make a large invisible, anchored, collision off block around it, then add a part into a script that when it touches the invisible area, it will teleport slightly to the correct space, anchor itself, play the animation to open the door, then change the destination to directly through the door, then set another destination after that to its end goal. :)

  • @britishmapping1759
    @britishmapping1759 11 หลายเดือนก่อน +1

    How do i remove the purple line? (fixed now)

  • @zeoIsas
    @zeoIsas 9 หลายเดือนก่อน +1

    hi is there a way to optimize this? its laggy when theres more than 1 player

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 ปีที่แล้ว +2

    I think I found a problem my 7 stud high Rig won't jump a 3 or 4 stud high jump. It will just sit there where it should of jumped but as soon as I make the jump 5 studs it will jump. I have tried changing the AgentHeight and I made sure that AgentCanJump is true

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Maybe try increasing the jump power? It’s in the humanoid

  • @sinnickle4357
    @sinnickle4357 หลายเดือนก่อน

    this is great, but for some reason the pathfinding takes a while to work when the script that calls it is enabled.

  • @Necicam
    @Necicam ปีที่แล้ว +5

    local rs = game:GetService("ReplicatedStorage")
    local forbidden = rs:WaitForChild("Forbidden")
    local ai = require(forbidden:WaitForChild("AI"))
    local NPC = script.Parent
    local target = workspace.dest
    wait(2)
    wait(2)
    ai.SmartPathfind(NPC.game.Players:GetChildren()[1],true,{Visualize = true, Tracking = true})
    wait(10)
    ai.Stop(NPC)
    wait(1)
    ai.SmartPathfind(NPC, game.Players:GetChildren()[1], true, {Visualize = true, Tracking = true})

    • @weebi7363
      @weebi7363 ปีที่แล้ว +2

      Not all heros wear capes💯💯

    • @deepdoz
      @deepdoz หลายเดือนก่อน

      he doesn't because there is a typo in the code. In line 11 he should've written: ai.SmartPathfind(NPC, game.Players...)
      He wrote it with a dot instead of a coma

  • @bacony12bruh
    @bacony12bruh 5 หลายเดือนก่อน

    550 subscriber❤

  • @JustArealfr
    @JustArealfr 3 หลายเดือนก่อน

    How would you know when the model has reached its endpoint?

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 ปีที่แล้ว +1

    I changed the jump power both up and down and still not jumping over 3 or 4 stud high blocks.

    • @jamesmcgillivray6741
      @jamesmcgillivray6741 ปีที่แล้ว

      here is my code
      local RS = game:GetService("ReplicatedStorage")
      local Forbidden = RS:WaitForChild("Forbidden")
      local AI = require(Forbidden:WaitForChild("AI"))
      local target = workspace:WaitForChild("target")
      local NPC = workspace.Rig
      AI.SmartPathfind(NPC,target,true,{AgentCanJump = true,Visualize = true,Tracking = false})

  • @HaileyStudios1213
    @HaileyStudios1213 3 หลายเดือนก่อน

    So it says No path could be found. This is an issue with Roblox, not Forbidden.

  • @Lennypennyez
    @Lennypennyez ปีที่แล้ว +4

    you guys need it to chase you even after it respawns: here!
    local rs = game:GetService("ReplicatedStorage")
    local forbidden = rs:WaitForChild("Forbidden")
    local ai = require(forbidden:WaitForChild("AI"))
    local NPC = script.Parent
    local targetPlayer = nil -- To keep track of the target player
    -- Function to start AI pathfinding
    local function StartPathfinding()
    ai.SmartPathfind(NPC, targetPlayer, true, {Visualize = true, Tracking = true})
    end
    -- Function to stop AI pathfinding
    local function StopPathfinding()
    ai.Stop(NPC)
    end
    -- Function to handle player character added event
    local function OnCharacterAdded(character)
    -- Update target player to the newly added character's player
    targetPlayer = game.Players:GetPlayerFromCharacter(character)
    -- Start pathfinding
    StartPathfinding()
    end
    -- Connect the player character added event
    game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(OnCharacterAdded)
    end)
    game.Players.PlayerRemoving:Connect(function(player)
    if player == targetPlayer then
    -- Player has left, stop pathfinding
    StopPathfinding()
    end
    end)
    -- Start initial pathfinding
    StartPathfinding()
    thank me later

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Good script! Maybe consider making duplicate npcs to target different players

    • @Lennypennyez
      @Lennypennyez ปีที่แล้ว

      @@CritDEV i did and had some fun with it!

    • @matt9559
      @matt9559 11 หลายเดือนก่อน

      @@Lennypennyez Thanks man. I was able to modify that script and have it working as expected for me. (UPDATE 2)
      local rs = game:GetService("ReplicatedStorage")
      local forbidden = rs:WaitForChild("Forbidden")
      local ai = require(forbidden:WaitForChild("AI"))
      local NPC = script.Parent
      local root = NPC.HumanoidRootPart
      local targetPlayer = nil
      local newtargetPlayer = nil
      local db = false
      local db1 = false
      function FindNearestPlayer()
      local minDistance = math.huge
      local nearestPlayer = nil
      for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
      local character = player.Character
      if character and character:FindFirstChild("Humanoid") and character.Humanoid.Health > 0 then
      local distance = (character.HumanoidRootPart.Position - root.Position).Magnitude
      if distance < minDistance then
      minDistance = distance
      nearestPlayer = player
      end
      end
      end
      return nearestPlayer
      end
      function StartPathfinding()
      while wait(1) do
      if db then return end
      db = true
      local bot = NPC:FindFirstChild("Bot")
      local botState = bot:GetState()
      if botState == Enum.HumanoidStateType.Seated or botState == Enum.HumanoidStateType.Swimming then
      task.wait(math.random(0.25, 1.5))
      bot:ChangeState(Enum.HumanoidStateType.Jumping)
      end
      wait()
      newtargetPlayer = FindNearestPlayer()
      if newtargetPlayer and newtargetPlayer == targetPlayer then
      if targetPlayer and targetPlayer.Character then
      ai.SmartPathfind(NPC, targetPlayer.Character, false, {Visualize = false, Tracking = true})
      end
      end
      wait()
      if newtargetPlayer and newtargetPlayer ~= targetPlayer then
      StopPathfinding()
      targetPlayer = newtargetPlayer
      if targetPlayer and targetPlayer.Character then
      ai.SmartPathfind(NPC, targetPlayer.Character, false, {Visualize = false, Tracking = true})
      end
      end
      --wait(5)
      db = false
      end
      end
      function StopPathfinding()
      ai.Stop(NPC)
      end
      function OnPlayerRemoving(player)
      if player == targetPlayer then
      StopPathfinding()
      end
      end
      function OnCharacterRemoving(character)
      local player = game.Players:GetPlayerFromCharacter(character)
      if player == targetPlayer then
      StopPathfinding()
      player.CharacterAdded:Connect(function(newCharacter)
      OnCharacterAdded(newCharacter)
      end)
      end
      end
      function OnCharacterAdded(character)
      targetPlayer = game.Players:GetPlayerFromCharacter(character)
      if targetPlayer and targetPlayer.Character then
      targetPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
      OnCharacterRemoving(targetPlayer.Character)
      end)
      end
      StartPathfinding()
      end
      function OnNPCSpawned()
      if targetPlayer and targetPlayer.Character then
      StartPathfinding()
      end
      end
      game.Players.PlayerAdded:Connect(function(player)
      player.CharacterAdded:Connect(OnCharacterAdded)
      end)
      game.Players.PlayerRemoving:Connect(OnPlayerRemoving)
      NPC.ChildAdded:Connect(function(child)
      if child:IsA("Humanoid") then
      OnNPCSpawned()
      end
      end)
      for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
      if player.Character then
      targetPlayer = player
      player.Character:WaitForChild("Humanoid").Died:Connect(function()
      OnCharacterRemoving(player.Character)
      end)
      StartPathfinding()
      end
      player.CharacterAdded:Connect(OnCharacterAdded)
      end

    • @LimiKatt
      @LimiKatt 11 หลายเดือนก่อน

      You're a life saver

    • @Emmett94
      @Emmett94 9 หลายเดือนก่อน

      bro is a lifesaver

  • @0KIT0771
    @0KIT0771 ปีที่แล้ว

    my npc is not moving i dont know what to do

  • @patata8457
    @patata8457 11 หลายเดือนก่อน +1

    is the module broken or is it just me
    i get an error from the module on line 139 saying
    attempt to index nil with 'StandardPathfindSettings'

    • @patata8457
      @patata8457 11 หลายเดือนก่อน +1

      My fault i accidentally put .Position at the end of the target arguement instead of the instance itself

  • @Anomic_raids
    @Anomic_raids 6 หลายเดือนก่อน

    Mine just flat out doesnt work at all

  • @f3n532
    @f3n532 4 หลายเดือนก่อน

    this is awesome but it says “attempt to index nil with ‘position’” on line 279

  • @cyrusdevs
    @cyrusdevs 5 หลายเดือนก่อน

    There's a flaw. For tracking players, if the NPC has a fast WalkSpeed (30-100) and gets close to the player, it slows down and doesn't maintain the fast speed.

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน +1

      There should be a parameter for swapping the method of movement @ x distance in settings. I’ll check soon

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน +1

      So this is not an issue with the API. You need to use the antilag script included or just put in a simple server script with this code
      NPCHumanoidRootPart:SetNetworkOwner(nil)

    • @cyrusdevs
      @cyrusdevs 5 หลายเดือนก่อน

      @@CritDEV I remember doing that with my NPCs I forgot to add that. I appreciate the response, my man.

  • @TheBuliderMCEpicChannel
    @TheBuliderMCEpicChannel 6 หลายเดือนก่อน

    Anything on having the AI stop targeting the player when dead? Currently trying to fix that but it seems that I cant stop the targeting on that same dead player.

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน

      Simply get player.Character.Humanoid.Health

  • @AlexiscoPlays
    @AlexiscoPlays ปีที่แล้ว +1

    didn't work for me.

  • @suikapuffin
    @suikapuffin 3 หลายเดือนก่อน

    StandardPathfindSettings, what is it.

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 ปีที่แล้ว

    how do I make my npc jump

  • @BlankJuice
    @BlankJuice 6 หลายเดือนก่อน

    I watched to the end and you said you would be making an advanced tutorial later but were is it? great tutorial I just need it to locate the nearest player

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน

      So i will but here’s how to do that.
      Loop through all players ( for i, player in pairs(game.Players:GetChildren()) do ),
      store two variables, nearPlayer and nearDist.
      To get distance do (pos1 - pos2).magnitude
      Should be simple from there

    • @BlankJuice
      @BlankJuice 6 หลายเดือนก่อน

      @@CritDEV Thx

    • @BlankJuice
      @BlankJuice 6 หลายเดือนก่อน

      @@CritDEV its a little confusing so I was wondering about you making a video on this and also how do I fix when a player dies the AI doesnt detect them?

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน

      @@BlankJuice the ai needs to be restarted whenever a new character is created

    • @BlankJuice
      @BlankJuice 6 หลายเดือนก่อน

      @@CritDEV okay

  • @Daber-wh5ug
    @Daber-wh5ug 11 หลายเดือนก่อน +3

    it dont work {Visualize = true, Tracking = true}) has a red line under it and it dont work

    • @user-hk1wv8hd2f
      @user-hk1wv8hd2f 5 วันที่ผ่านมา

      hey i have the same problem did you figure it out yet?

  • @stanciooliver2745
    @stanciooliver2745 10 หลายเดือนก่อน +1

    I don't know why but when it visualize it just stops at the second point of the visual but when it just has to use line of sight or when the part is close. It has no problems

    • @CritDEV
      @CritDEV  10 หลายเดือนก่อน

      That’s weird. Send a video if you can of it happening

    • @Cocodado
      @Cocodado 9 หลายเดือนก่อน

      @@CritDEV The same thing happened to me
      There is this error : Unable to assign property Value. Object expected, got PathWaypoint

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน

      @@Cocodado send the code you had when the error happened

    • @Cocodado
      @Cocodado 9 หลายเดือนก่อน

      @@CritDEV Anyways, it's working now.

  • @weirdsweapons
    @weirdsweapons 11 หลายเดือนก่อน +1

    Would it be possible to make a flee function for the API. I haven't actually used the API yet so this might already be a feature but it doesn't look like it's in the API.

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน +1

      I believe that’d be easy to code yourself. Save any location you would want it to flee to then pathfind it to that location without tracking. You could also make a part for it to track and then move that part where you want it to go

    • @weirdsweapons
      @weirdsweapons 11 หลายเดือนก่อน

      @@CritDEV (I don't mean wander when I say flee) I have a bunch of maps and it would take a long time for me to add a bunch of flee points to all of them. Is there a way that I could automate the process?

  • @margwa_slayer2972
    @margwa_slayer2972 9 หลายเดือนก่อน

    How do I make the balls invisible
    EDIT: Nevermind just set visualize to FALSE

  • @matt9559
    @matt9559 ปีที่แล้ว +2

    You should fix the part where when the NPC chases the player, and kills the player and the player respawns, it stops chasing with the player

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      That’s a feature in my opinion. You can add that yourself by detecting when a player respawns using charadded

    • @matt9559
      @matt9559 ปีที่แล้ว +1

      @@CritDEV It works well, but now when the NPC dies, it doesn't chase any players after it respawns.

    • @AdvancedAnimator
      @AdvancedAnimator 5 หลายเดือนก่อน

      @@CritDEV Sorry to bother you, but how do i do it? How to detect if a player respawns using "charadded"? I'm a beginner who is looking forward to create a horror game.

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน

      @@AdvancedAnimator Player.CharacterAdded:Connect(function() - code end)

  • @cladaigh
    @cladaigh 8 หลายเดือนก่อน

    it doesnt work for me

  • @Stefan_IC
    @Stefan_IC ปีที่แล้ว +1

    I built a rig and done what you did, but still nothing worked

    • @CritDEV
      @CritDEV  ปีที่แล้ว +1

      Unfortunately the API seems to work half the time. I’d recommend finding a path finding tutorial else where

  • @user-ew6co3bm1b
    @user-ew6co3bm1b 6 หลายเดือนก่อน

    It’s not working for me

  • @keshido1
    @keshido1 3 หลายเดือนก่อน

    The player pathfinding doesnt work its saying the forbidden ai attempt to index nil with ‘position’

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      You are passing an object or thing that no longer exists

  • @yousefsaleh3562
    @yousefsaleh3562 7 หลายเดือนก่อน

    Full of bugs when It requires jumping

  • @keshido1
    @keshido1 3 หลายเดือนก่อน

    the script does not workkkk

  • @taywanjesuper5954
    @taywanjesuper5954 6 หลายเดือนก่อน

    how do i make it unlaggy with track on cuz i dont know what u meant by using setnetworkowner and how to setup tha antilag so would u help me?

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน +1

      HumanoidRootPart:SetNetworkOwner(nil) in a regular script
      Make sure you use WaitForChilds and etc…

    • @taywanjesuper5954
      @taywanjesuper5954 6 หลายเดือนก่อน

      @@CritDEV thank you though didnt help but i think it will be fixed in new updates (atleast i hope) =D

  • @animebinger7974
    @animebinger7974 7 หลายเดือนก่อน

    I noticed in the AI modulescript that there's a los(line of sight) check. Any idea on how to actually use it? I'm trying to make it call ai.Stop(NPC when line of sight is gained, but I can't figure out how. If I put ai.Stop(NPC) into a loop and if statement, it says that ai is outside the active table.
    I have a sneaking suspicion that there's already a way and that I'm just being stupid.
    edit: I also noticed that it's actually already being called, but I can't figure out where. I placed a print statement and it prints, but I cannot find the place where losCheck is being called.

    • @CritDEV
      @CritDEV  7 หลายเดือนก่อน

      std.Math.LineOfSight
      Make sure to require the std module or just the math module

    • @animebinger7974
      @animebinger7974 7 หลายเดือนก่อน

      @@CritDEV Holy crap ty!

    • @CritDEV
      @CritDEV  7 หลายเดือนก่อน

      @@animebinger7974 just in case you are planning it. Tracking mode automatically switches to the normal MoveTo call instead of pathfinding when the NPC is in line of sight

    • @animebinger7974
      @animebinger7974 7 หลายเดือนก่อน

      @@CritDEV Yea I found that surprising. Forbidden is amazing c:

  • @dogeball2628
    @dogeball2628 2 หลายเดือนก่อน

    Sometimes the NPC doesn't jump, how can I fix that?

    • @CritDEV
      @CritDEV  2 หลายเดือนก่อน

      I do not know. It is hard coded to do so from Roblox’s pathfinding system.
      You can externally trigger a jump by placing a part where it commonly gets stuck and when the AI touches it set Jump in the humanoid to true

  • @therandomgamermonkey6259
    @therandomgamermonkey6259 ปีที่แล้ว

    Yay I can make a horror game

  • @Rkyiel
    @Rkyiel หลายเดือนก่อน

    How can I make it constantly update to the new part's position if the part moves?

    • @CritDEV
      @CritDEV  หลายเดือนก่อน

      Set tracking to true

    • @Rkyiel
      @Rkyiel หลายเดือนก่อน

      @@CritDEV thx

  • @doctext-jose.e-3484
    @doctext-jose.e-3484 9 หลายเดือนก่อน

    i would like to know more about ai , could you not only make a video about all commands about the api and also make tutorials about ai? you seem like a dude who knows

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน

      maybe depends on what happens in my life. If I have time and I’m not sick I’ll do it

  • @DarkThePurple
    @DarkThePurple 8 หลายเดือนก่อน

    Does it work ignoring all parts that can collide are false? So they can walk through it

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน

      Yeah I think thats a Roblox feature for the Pathfinding Service

  • @fv2536
    @fv2536 9 หลายเดือนก่อน

    for some majestic reason if i try to call the SmartPathfind function then i get an error saying something along the lines of "SmartPathfind is not a valid member of module script "AI"" and it doesn't work at all. does anyone know why this is happening? I even tried copying the EXACT code in the video and i got the same issue

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน

      Make sure you did require(ai)

    • @fv2536
      @fv2536 9 หลายเดือนก่อน

      @@CritDEVi can't believe i forgot that. many thanks

    • @fv2536
      @fv2536 9 หลายเดือนก่อน

      @@CritDEVnevermind this time it still doesn't work, but there are no errors. and the path doesn't get visualized even when i set that value to true, does the API work with custom made characters or is it just for regular R6 and R15 roblox npcs?

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน

      @@fv2536 the error you originally got is unrelated to that. But as long as the entity has a humanoid and Motor6Ds it’ll work

    • @fv2536
      @fv2536 9 หลายเดือนก่อน

      @@CritDEV everything is unanchored, it has a humanoid, it has all the necessary Motor6Ds, it functions like an npc should. could there be any other reason why the api does not work? did it by any chance get broken recently due to roblox updates?

  • @Neqkoo
    @Neqkoo 3 หลายเดือนก่อน

    Is lagging when the NPC is too far, any way to fix this?

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      A recommendation would be not to use tracking when someone is far away

  • @left2841
    @left2841 6 หลายเดือนก่อน

    it doesn't work

  • @F7RBeast
    @F7RBeast 9 หลายเดือนก่อน

    Hey Critixx, nice vid. btw i have 2 question:
    1- how do i get rid of the purple balls of tracking?
    2- how do i make him follow a player in a certain radius, let's say 30 block radius?
    please answer as quickly as possible , i have a school project to do and i'm doing it in roblox

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน +1

      1: Just set visualize to false
      2: Run a loop and do if (Player.Character.HumanoidRootPart - NPC.HumanoidRootPart).magnitude

    • @F7RBeast
      @F7RBeast 9 หลายเดือนก่อน

      @@CritDEV no thank you the video was helpful and so were you. thank you so much

    • @Royal23458
      @Royal23458 8 หลายเดือนก่อน

      @@CritDEV Where do i put the loop? And the code you said

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน

      @@Royal23458 unfortunately since I do not know what you are doing I’m unable to really help. I’d highly encourage you to watch a Lua tutorial.

    • @Royal23458
      @Royal23458 8 หลายเดือนก่อน

      @@CritDEV I made comment, so basically kind of like a zombie following you when u get in a distance from it

  • @masterwallace4268
    @masterwallace4268 ปีที่แล้ว +1

    I have a pathfinding bug when handling with multiple enemies with one script. I am currently finding a fix at the moment. If you have any ideas or suggestions let me know. Here’s a video th-cam.com/video/ec6feocxMhA/w-d-xo.html

    • @masterwallace4268
      @masterwallace4268 ปีที่แล้ว

      Update: I have found a general fix for this. While looping through the waypoints, I am skipping the first 5 waypoints to prevent the enemy from jittering

  • @masterwallace4268
    @masterwallace4268 ปีที่แล้ว +1

    Hey there. Do you think it’s possible you can create a function that can return if the path is passable?

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Yeah I would save the location from where the pathfind started and repathfind to that location.
      I believe it accepts Vector3’s

    • @masterwallace4268
      @masterwallace4268 ปีที่แล้ว +1

      @@CritDEV never mind I looked at your code and it’s very simple to do. Sorry but thank you for the help!

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      @@masterwallace4268 good luck! let me know if you find any bugs

    • @badprong2556
      @badprong2556 ปีที่แล้ว

      @@CritDEV yo does this work on r6 models?

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      @@badprong2556 should

  • @timjitz2708
    @timjitz2708 ปีที่แล้ว +1

    Is there any way to add a walking animation to the pathfinding AI?

    • @CritDEV
      @CritDEV  ปีที่แล้ว +1

      That would be the standard way to edit animations in NPCs. I’m sure there are many tutorials out there

    • @timjitz2708
      @timjitz2708 ปีที่แล้ว

      So I figured it out. So what you have to do is simply put the "Animate" script that you would find in the player or when you spawn a Rig via roblox and convert it into a server script.

  • @0_0fakei18
    @0_0fakei18 6 หลายเดือนก่อน

    Is there a way to change the target while pathfinding (chase the nearest player)?

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน

      Make a loop. If the targeted player is different than the new closest player than call ai.stop(NPC) and ai.SmartPathfind(NPC, newtarget , etc…)
      Simple loops, must be in a server script, I recommend using runservice.PhysicsStepped:Wait() as the delay in the loop

    • @0_0fakei18
      @0_0fakei18 6 หลายเดือนก่อน

      @@CritDEV thank you

  • @firedragon7891
    @firedragon7891 5 หลายเดือนก่อน

    this is amazing and all but how do i make it track and follow a player? because i wanna use this for my game

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน

      you call it with the target as the player and tracking on true

    • @firedragon7891
      @firedragon7891 5 หลายเดือนก่อน

      @@CritDEV ok thx i will try this tomorrow

  • @DarkestGames86
    @DarkestGames86 6 หลายเดือนก่อน

    Here is my comment as a roblox developer saying this is great. now because 9/10 coders already recommended this, it is my obligation to NOT recommend this because I am the 1/10 >:D (Also, please add support for inputting a vector3 value instead of only takin in instances, thank you)

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน

      support is coded I’ll push it soon along with a new datastore system

  • @seklerne
    @seklerne 3 หลายเดือนก่อน

    By the way character makes too much lag somehow. how to fix it i need a reply for this, pls

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      Please drag and drop the included AntiLag script into your npc :).

    • @seklerne
      @seklerne 3 หลายเดือนก่อน

      @@CritDEV bro me and my friend tried to fix it and it worked and thank you so much for the ai bro🤯🙏

  • @Royal23458
    @Royal23458 8 หลายเดือนก่อน

    Thank you! quick question though, how do i make it stop so hes not like rubbing against me?

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน

      oh also put another script that sets the HumanoidRootPart:SetNetworkOwner(nil)
      idk if that’s in the tutorial but it prevents lag

    • @Royal23458
      @Royal23458 8 หลายเดือนก่อน

      @@CritDEV Okay! Thanks.

  • @42N4K
    @42N4K หลายเดือนก่อน

    how can you make it chase the nearest player?

    • @CritDEV
      @CritDEV  หลายเดือนก่อน

      Do a loop to get (playerpart - enemy part).magnitude for each one.
      Store the current closest player and distance and at the end of the loop you’ll have your target.
      You can also have a loop running in the background to detect if the closest player changed and call API.stop(enemy) and reset it.

  • @nothing2e12as
    @nothing2e12as 5 หลายเดือนก่อน

    How can i set much more tracking location and to be in loop ?

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน

      please elaborate? What do you mean by much more tracking location and being in loop

    • @nothing2e12as
      @nothing2e12as 5 หลายเดือนก่อน

      @@CritDEV i fix all of that but how can i stop the NPC instantly
      local rs = game:GetService("ReplicatedStorage")
      local forbidden = rs:WaitForChild("Forbidden")
      local ai = require(forbidden:WaitForChild("AI"))
      local NPC = script.Parent
      local function RandomLocation()
      local locations = {
      workspace.Points.Part1,
      workspace.Points.Part2,
      workspace.Points.Part3,
      workspace.Points.Part4,
      workspace.Points.Part5,
      workspace.Points.Part6,
      workspace.Points.Part7,
      workspace.Points.Part8,
      workspace.Points.Part9,
      workspace.Points.Part10
      }
      return locations[math.random(1, #locations)]
      end
      local target = RandomLocation()
      while true do
      wait(0.1)
      if script.Parent.Status.Walking.Value == true then
      ai.SmartPathfind(NPC,target,true,{Visualize = true, Tracking = false})
      target = RandomLocation()
      else
      print("NPC Stop walking")
      ai.Stop(NPC)
      end
      end

  • @helloneighborsmosh806
    @helloneighborsmosh806 8 หลายเดือนก่อน

    how do i make this go towards different waypoints and also damage the player

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน +1

      don’t know what you mean by go toward different waypoints but for the damage you just put a script inside the HRT and do
      local db = false - stops script from running thousands of times a second
      local damageCooldownTimer = 1 - seconds
      HRT.Touched:Connect(function(hit)
      local enemyChar = nil
      if hit.Parent:FindFirstChild(“HumanoidRootPart) then enemyChar = hit.Parent end
      if hit.Parent.Parent:FindFirstChild(“HumanoidRootPart) then enemyChar = hit.Parent.Parent end
      if enemyChar == nil then return end
      db = true
      - damage code here
      wait(damageCooldownTimer)
      db = false
      end)

    • @helloneighborsmosh806
      @helloneighborsmosh806 8 หลายเดือนก่อน

      @@CritDEV Thanks! and what i meant by different waypoints is like the ai patrolling to other points yknow like walking back n forth between points

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน

      There is a yield setting when you call the function.
      Yielding is basically where it will stop further execution of the lines of code after the function call if true. Just make it so that it’s a loop and pathfinds between those locations after the previous pathfind finishes

  • @SuperAngel2384
    @SuperAngel2384 10 หลายเดือนก่อน +2

    is there a way to make it so if a player is a certain distance from the NPC that it stops what it's doing and goes after the player?

    • @AlexOnVR_alt
      @AlexOnVR_alt 7 หลายเดือนก่อน +1

      isnt possible with the api. try this tho!
      local Forbidden = game.ReplicatedStorage.Forbidden
      local AI = require(Forbidden.AI)
      local function GetNearestPlayer()
      local CurrentPlayer = nil
      for _,v in pairs(game.Players:GetChildren()) do
      if v:IsA("Player") then
      if CurrentPlayer == nil then
      CurrentPlayer = v.Character
      else
      if CurrentPlayer.HumanoidRootPart.Position.Magnitude < v.Character.HumanoidRootPart.Position.Magnitude then
      CurrentPlayer = v.Character
      end
      end
      end
      wait(.025)
      end
      return CurrentPlayer
      end
      wait(1)
      while wait(1) do
      local Player = GetNearestPlayer()
      wait(.5)
      AI.SmartPathfind(script.Parent, Player, false, {Visualize = false, Tracking = false})
      end
      (put forbidden in replicatedStorage)

    • @AlexOnVR_alt
      @AlexOnVR_alt 7 หลายเดือนก่อน +1

      btw all this code is mine

    • @AlexOnVR_alt
      @AlexOnVR_alt 7 หลายเดือนก่อน +1

      except forbidden api :]

  • @CapybaraGamingPC
    @CapybaraGamingPC ปีที่แล้ว

    how do i make the npc jum

    • @CritDEV
      @CritDEV  ปีที่แล้ว +1

      I believe I have somewhere in the settings the default pathfinding settings, in there set AgentCanJump to true. If it isn’t jumping it could also be due to the humanoids jump power

  • @фута
    @фута 3 หลายเดือนก่อน

    just tried on my game, rly badly calculates paths

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      Is Roblox’s pathfinding mechanism…

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      To enhance your results, use the StandardPathfindingSettings and other values to optimize your path, as well as the pathfinding blockers (object)

  • @40_ton55
    @40_ton55 16 วันที่ผ่านมา

    Could this be used with aircraft?

    • @CritDEV
      @CritDEV  16 วันที่ผ่านมา

      @@40_ton55 probably not.

  • @avidyoutubewatcher1897
    @avidyoutubewatcher1897 11 หลายเดือนก่อน +1

    Is there a way to modify the speed of the agent?

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน

      Walkspeed of the humanoid

    • @avidyoutubewatcher1897
      @avidyoutubewatcher1897 11 หลายเดือนก่อน

      @@CritDEV I see, thx for the speedy reply.

    • @avidyoutubewatcher1897
      @avidyoutubewatcher1897 11 หลายเดือนก่อน

      I noticed it's not jumping either even though I have Auto Jump enabled on the humanoid? @@CritDEV

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน

      @@avidyoutubewatcher1897 In the settings there is a DefaultPathfindingSettings table, in that set AgentCanJump to true

  • @omittingsteveyt3466
    @omittingsteveyt3466 ปีที่แล้ว +1

    I did everything right but it didn't work the dummy was unanchored aswell. Any help?:
    local rs = game:GetService("ReplicatedStorage")
    local forbidden = rs:WaitForChild("Forbidden")
    local ai = require(forbidden:WaitForChild("AI"))
    local NPC = script.Parent
    local target = workspace.dest
    wait(2)
    ai.SmartPathfind(NPC,game.Players:GetChildren()[1],true,{Visualize = true, Tracking = true})

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Is there an error code that printed

    • @omittingsteveyt3466
      @omittingsteveyt3466 ปีที่แล้ว

      @@CritDEV I will check soon

  • @rattle_dash
    @rattle_dash 5 หลายเดือนก่อน

    is it possible to use this for a tower defense
    game

    • @CritDEV
      @CritDEV  5 หลายเดือนก่อน

      No that involves using nodes which is a different method of pathing NPCs

    • @rattle_dash
      @rattle_dash 5 หลายเดือนก่อน

      @@CritDEV ok thanks

  • @jellyii8886
    @jellyii8886 6 หลายเดือนก่อน

    What would happen if there is no path available?

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน +1

      It wouldn’t run the pathfind.
      It also returns this which can be used in your code! Enum.PathStatus.NoPath (only when yield = true

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน +1

      Give me a hour and I’ll push the update. Redownload the module at 5

    • @jellyii8886
      @jellyii8886 6 หลายเดือนก่อน

      Thank you!@@CritDEV

  • @zombie_gamer2122
    @zombie_gamer2122 12 วันที่ผ่านมา

    Literally nothing works for me.

    • @CritDEV
      @CritDEV  12 วันที่ผ่านมา

      @@zombie_gamer2122 Please send a code sample.

  • @user-ud7zt5dt31
    @user-ud7zt5dt31 7 หลายเดือนก่อน

    how to set max chase distance?

    • @CritDEV
      @CritDEV  7 หลายเดือนก่อน

      Range of pathfind in settings

    • @user-ud7zt5dt31
      @user-ud7zt5dt31 7 หลายเดือนก่อน

      AgentRadius?

  • @numberoneshiteater
    @numberoneshiteater 3 หลายเดือนก่อน

    is there a way i can check if the path is finished?

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      Turn on visualize

    • @numberoneshiteater
      @numberoneshiteater 3 หลายเดือนก่อน

      @@CritDEV yeah but i mean like detect if path is finished

    • @CritDEV
      @CritDEV  3 หลายเดือนก่อน

      @@numberoneshiteater I believe it returns true if you have yielding off if it was completed. Or Enum.PathfindingStatus.Success

  • @yousefsaleh3562
    @yousefsaleh3562 7 หลายเดือนก่อน

    Is this good performance-wise?

    • @CritDEV
      @CritDEV  7 หลายเดือนก่อน

      Tracking is not. Otherwise, it is

  • @chosenone3
    @chosenone3 วันที่ผ่านมา +1

    CritDev my comments keep disapearing for some reason on your reply so can you continue on here:
    i changed it but it doesnt work I put a video on my channel showing the issue though

    • @CritDEV
      @CritDEV  วันที่ผ่านมา

      Can you send the call you used ?

    • @CritDEV
      @CritDEV  วันที่ผ่านมา

      Also for future reference in case you ever need it.
      Making a video not made for kids does not mean 13+, 18+, etc...
      it only allows for features like commenting and such and recommends videos for different audiences.

    • @chosenone3
      @chosenone3 วันที่ผ่านมา +1

      @@CritDEV oh my bad I didnt know. but heres the call its simple really: ai.SmartPathfind(troop, hit, true, {Visualize = true, tracking = true}) the troop being the npc, and hit being the part the mouse hit. and I tried playing around with changing SwapMovementMethodDistance in the settings table but nothings changing

    • @CritDEV
      @CritDEV  วันที่ผ่านมา

      @@chosenone3 in a day or so I will have tested and pushed a new version of the AI module, completely rewritten. I’m not going to rush it and I’m going to make sure it’s fully tested but it is “developed”
      The issue is random problems which make pathfinding asynchronously the most annoying thing I’ve ever dealt with.

    • @chosenone3
      @chosenone3 วันที่ผ่านมา +1

      @@CritDEV alright I’m looking forward to it thank u good luck 🙏

  • @THE_GOLDENSPECTRA
    @THE_GOLDENSPECTRA 8 วันที่ผ่านมา

    Why doesn’t not work😢

    • @CritDEV
      @CritDEV  7 วันที่ผ่านมา

      @@THE_GOLDENSPECTRA please send a sample of your call so I can help you debug.

    • @THE_GOLDENSPECTRA
      @THE_GOLDENSPECTRA 7 วันที่ผ่านมา

      @@CritDEV ok

  • @Ayenisko
    @Ayenisko 4 วันที่ผ่านมา +1

    I don’t understand it

    • @CritDEV
      @CritDEV  3 วันที่ผ่านมา

      Please tell me what confuses you so I can help.

    • @Ayenisko
      @Ayenisko 2 วันที่ผ่านมา

      @@CritDEV Om new to developing

  • @persona8614
    @persona8614 ปีที่แล้ว +1

    doesnt work did all you did

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      Yeah I know, and I don’t know why cause I’ve looked through all the code over and over

    • @Psygenz
      @Psygenz ปีที่แล้ว

      @@CritDEV I'm pretty sure it's because the enemyroot is nil. I've done some prints on the AI ModuleScript and it just says the enemyroot = nil.

    • @CritDEV
      @CritDEV  ปีที่แล้ว

      @Psygenz I’ll make it so that if enemyroot == nil then it ends the patthfind

    • @Psygenz
      @Psygenz ปีที่แล้ว

      It's most likely because the Humanoid name is not "Humanoid"

    • @Psygenz
      @Psygenz ปีที่แล้ว

      @@CritDEV 👍

  • @пхпх
    @пхпх 2 หลายเดือนก่อน

    yo why this AI is kinda stupd :c
    Just tested on easiest parkour and it just can't jump

    • @CritDEV
      @CritDEV  2 หลายเดือนก่อน

      Roblox’s pathfinding system is not meant to be a smart ai.
      It is just meant to try to path to players.
      Should you want an actual artificial intelligence, you have to make your own.

  • @michaelpizzasready7063
    @michaelpizzasready7063 6 หลายเดือนก่อน

    whyyyyy do I always need to download something suspicious??!?!?!?! Please just make a full tutorial instead of making everyone download some random model or plugin!

    • @CritDEV
      @CritDEV  6 หลายเดือนก่อน +1

      . . . You can go through the code on only the ai module and see. 🤷

    • @fitmotheyap
      @fitmotheyap วันที่ผ่านมา

      Have you seen how much code these models and plugins have 😭
      Also they are tools to make things way easier, veeeery grateful for it

  • @juhmop
    @juhmop 4 หลายเดือนก่อน

    too laggy

    • @CritDEV
      @CritDEV  4 หลายเดือนก่อน

      If the lag you are seeing is when the player is near the NPC please add and enable the included anti lag script to the NPC :)

    • @juhmop
      @juhmop 4 หลายเดือนก่อน

      @@CritDEV is it supposed to even handle like 100 dummies

    • @CritDEV
      @CritDEV  4 หลายเดือนก่อน

      @@juhmop Not with tracking enabled.

  • @Fastboy_Gaming
    @Fastboy_Gaming 6 หลายเดือนก่อน +1

    Learn to code better

  • @Tnt0322
    @Tnt0322 11 หลายเดือนก่อน

    is there a way to contact you? discord etc.

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน

      unfortunately no, but I believe it would be better if you found an alternative video on this topic and used their method instead of this script