How to PATHFIND in Roblox 2024 using Forbidden

Sdílet
Vložit
  • čas přidán 9. 09. 2024
  • #robloxdev #robloxcode #roblox #robloxdeveloper #roblox #pathfinding
    Link to API: www.roblox.com...
    new create web link: create.roblox....
    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
  • Hry

Komentáře • 298

  • @CritDEV
    @CritDEV  Před rokem +13

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

    • @ConeParty
      @ConeParty Před 11 měsíci

      It is forbidden to unsubscribe to you

    • @HeroDevv
      @HeroDevv Před 8 měsíci +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  Před 8 měsíci +1

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

    • @YeaIDoStuff
      @YeaIDoStuff Před 7 měsíci

      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  Před 7 měsíci

      @@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”]

  • @aspirin4279
    @aspirin4279 Před rokem +56

    I came here by watching yt shorts

  • @patriot7260
    @patriot7260 Před 8 měsíci +8

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

    • @maciezez
      @maciezez Před měsícem

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

    • @draculearx6801
      @draculearx6801 Před 22 dny

      @@maciezez you know he made the kit SO that everyone can do this right?

  • @soundsofjupiter2859
    @soundsofjupiter2859 Před rokem +5

    very cool lookin forward to updates

  • @Necicam
    @Necicam Před rokem +9

    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 Před rokem +2

      Not all heros wear capes💯💯

    • @deepdoz
      @deepdoz Před 2 měsíci

      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

  • @hutcle
    @hutcle Před 8 měsíci +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

  • @turbs1348
    @turbs1348 Před 7 měsíci +2

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

  • @CopyStudiosFilms
    @CopyStudiosFilms Před 10 měsíci +2

    THIS MAN IS HEAVILY UNDERRATED!

  • @AnOnex-
    @AnOnex- Před 7 dny

    You saved my game! This is going to help me so much.

  • @taywanjesuper5954
    @taywanjesuper5954 Před 7 měsíci +1

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

  • @Sugar._.Stxrrr
    @Sugar._.Stxrrr Před 3 měsíci +1

    This was so helpful tysm 😭

  • @lemonslice4507
    @lemonslice4507 Před rokem +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  Před rokem

      Use the apis line of sight function

  • @galvanygames1441
    @galvanygames1441 Před rokem +1

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

    • @Daber-wh5ug
      @Daber-wh5ug Před rokem

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

  • @Ismail_NotFullName
    @Ismail_NotFullName Před 7 měsíci

    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

  • @JustArealfr
    @JustArealfr Před 5 měsíci +1

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

  • @YoungBassAngler
    @YoungBassAngler Před rokem +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  Před rokem +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 Před rokem

      Alright. Again, I really appreciate it
      @@CritDEV

    • @JJsStuff
      @JJsStuff Před rokem +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 Před 8 měsíci

      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. :)

  • @KrypDeveloper
    @KrypDeveloper Před 11 dny

    Make yourself: ❌️
    Use a API that can broke code in future: ✅️

  • @brawldude2656
    @brawldude2656 Před měsícem

    Remember guys best pathfinding agorithm is always the integrated ones with your own waypoints

  • @Daber-wh5ug
    @Daber-wh5ug Před rokem +3

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

    • @Mr_guy-RBLX
      @Mr_guy-RBLX Před měsícem

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

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 Před rokem +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  Před rokem

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

  • @user-cw1ow1cv2f
    @user-cw1ow1cv2f Před 11 měsíci +1

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

  • @Yuilix
    @Yuilix Před 2 měsíci

    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

  • @DomExists
    @DomExists Před 11 měsíci +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?

  • @matt9559
    @matt9559 Před rokem +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  Před rokem

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

    • @matt9559
      @matt9559 Před rokem +1

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

    • @AdvancedAnimator
      @AdvancedAnimator Před 6 měsíci

      @@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  Před 6 měsíci

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

  • @Lennypennyez
    @Lennypennyez Před rokem +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  Před rokem

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

    • @Lennypennyez
      @Lennypennyez Před rokem

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

    • @matt9559
      @matt9559 Před rokem

      @@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 Před rokem

      You're a life saver

    • @Enigmatic-v83
      @Enigmatic-v83 Před 11 měsíci

      bro is a lifesaver

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 Před rokem +1

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

    • @jamesmcgillivray6741
      @jamesmcgillivray6741 Před rokem

      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})

  • @patata8457
    @patata8457 Před rokem +2

    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 Před rokem +1

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

  • @sinnickle4357
    @sinnickle4357 Před 3 měsíci

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

  • @Jagrio
    @Jagrio Před rokem +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 Před rokem

      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})

  • @zeoIsas
    @zeoIsas Před 11 měsíci +1

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

  • @britishmapping1759
    @britishmapping1759 Před rokem +1

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

  • @AlexiscoPlays
    @AlexiscoPlays Před rokem +1

    didn't work for me.

  • @cyrusdevs
    @cyrusdevs Před 7 měsíci

    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  Před 7 měsíci +1

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

    • @CritDEV
      @CritDEV  Před 7 měsíci +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 Před 7 měsíci

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

  • @stanciooliver2745
    @stanciooliver2745 Před 11 měsíci +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  Před 11 měsíci

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

    • @Cocodado
      @Cocodado Před 11 měsíci

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

    • @CritDEV
      @CritDEV  Před 11 měsíci

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

    • @Cocodado
      @Cocodado Před 11 měsíci

      @@CritDEV Anyways, it's working now.

  • @HaileyStudios1213
    @HaileyStudios1213 Před 5 měsíci

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

  • @weirdsweapons
    @weirdsweapons Před rokem +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  Před rokem +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 Před rokem

      @@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?

  • @f3n532
    @f3n532 Před 5 měsíci

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

  • @craycraycat13
    @craycraycat13 Před 14 dny

    hi, this is a really helpful video bc i hate roblox's pathfinding system. however, i'm not sure how to see when my NPC has gotten to its target part.

    • @CritDEV
      @CritDEV  Před 14 dny

      @@craycraycat13 you can use .Touched on the part.
      Later on Forbidden will include events to hook to as such

    • @craycraycat13
      @craycraycat13 Před 14 dny

      @@CritDEV thank you

  • @BlankJuice
    @BlankJuice Před 7 měsíci

    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  Před 7 měsíci

      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 Před 7 měsíci

      @@CritDEV Thx

    • @BlankJuice
      @BlankJuice Před 7 měsíci

      @@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  Před 7 měsíci

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

    • @BlankJuice
      @BlankJuice Před 7 měsíci

      @@CritDEV okay

  • @bacony12bruh
    @bacony12bruh Před 6 měsíci

    550 subscriber❤

  • @Stefan_IC
    @Stefan_IC Před rokem +1

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

    • @CritDEV
      @CritDEV  Před rokem +1

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

  • @TheBuliderMCEpicChannel
    @TheBuliderMCEpicChannel Před 8 měsíci

    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  Před 8 měsíci

      Simply get player.Character.Humanoid.Health

  • @yousefsaleh3562
    @yousefsaleh3562 Před 8 měsíci

    Full of bugs when It requires jumping

  • @dogeball2628
    @dogeball2628 Před 4 měsíci

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

    • @CritDEV
      @CritDEV  Před 4 měsíci

      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

  • @Anomic_raids
    @Anomic_raids Před 7 měsíci

    Mine just flat out doesnt work at all

  • @keshido1
    @keshido1 Před 5 měsíci

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

    • @CritDEV
      @CritDEV  Před 5 měsíci

      You are passing an object or thing that no longer exists

  • @DarkestGames86
    @DarkestGames86 Před 7 měsíci

    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  Před 7 měsíci

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

  • @masterwallace4268
    @masterwallace4268 Před rokem +1

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

    • @CritDEV
      @CritDEV  Před rokem

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

    • @masterwallace4268
      @masterwallace4268 Před rokem +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  Před rokem

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

    • @badprong2556
      @badprong2556 Před rokem

      @@CritDEV yo does this work on r6 models?

    • @CritDEV
      @CritDEV  Před rokem

      @@badprong2556 should

  • @G102theChair
    @G102theChair Před 28 dny

    It will go for the destination part thing but when i try it on players it says me " No path could be found. This is an issue with Roblox, not Forbidden. The NPC might also not be able to fit where the waypoint is, please see 'AgentRadius' " and I do not understand it!

    • @CritDEV
      @CritDEV  Před 28 dny

      @@G102theChair
      the error is basically saying that Roblox’s pathfinding solution could not reach the target.
      please join discord for more help.

    • @G102theChair
      @G102theChair Před 28 dny

      @@CritDEV I don't have discord.

    • @CritDEV
      @CritDEV  Před 28 dny

      @@G102theChair well in that case, the only way I can help is by saying to make sure the space the AI is trying to go to is at least 6 studs if you do not change the StandardPathfindSettings.

    • @G102theChair
      @G102theChair Před 28 dny +1

      @@CritDEV Ah the problem was the spawnpoint, it spawns my character in mid air.

  • @keshido1
    @keshido1 Před 5 měsíci

    the script does not workkkk

  • @F7RBeast
    @F7RBeast Před 10 měsíci

    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  Před 10 měsíci +1

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

    • @F7RBeast
      @F7RBeast Před 10 měsíci

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

    • @RoyaItee
      @RoyaItee Před 9 měsíci

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

    • @CritDEV
      @CritDEV  Před 9 měsíci

      @@RoyaItee 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.

    • @RoyaItee
      @RoyaItee Před 9 měsíci

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

  • @timjitz2708
    @timjitz2708 Před rokem +1

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

    • @CritDEV
      @CritDEV  Před rokem +1

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

    • @timjitz2708
      @timjitz2708 Před rokem

      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.

  • @Neqkoo
    @Neqkoo Před 5 měsíci

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

    • @CritDEV
      @CritDEV  Před 5 měsíci

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

  • @suikapuffin
    @suikapuffin Před 4 měsíci

    StandardPathfindSettings, what is it.

  • @doctext-jose.e-3484
    @doctext-jose.e-3484 Před 10 měsíci

    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  Před 10 měsíci

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

  • @QUEEN_UA
    @QUEEN_UA Před rokem

    my npc is not moving i dont know what to do

  • @ITssShawnVr
    @ITssShawnVr Před 7 dny

    what if you change it with a diffirent monster

    • @CritDEV
      @CritDEV  Před 7 dny

      @@ITssShawnVr it should work, just provide the correct StandardPathfindSettings if the size is different,
      For details on what should be provided in that table, see Roblox’s “Character Pathfinding”

  • @Rkyiel
    @Rkyiel Před 2 měsíci

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

    • @CritDEV
      @CritDEV  Před 2 měsíci

      Set tracking to true

    • @Rkyiel
      @Rkyiel Před 2 měsíci

      @@CritDEV thx

  • @arctalgamez
    @arctalgamez Před 16 dny

    It works for the part but when I change it to look for the player it doesn't work. I don't know why. The rig is R6 and my character is R15 is this the issue?

    • @CritDEV
      @CritDEV  Před 15 dny

      @@arctalgamez that should not be the problem. Please join the discord for help

    • @arctalgamez
      @arctalgamez Před 15 dny

      @@CritDEV actually, it was the problem. I changed it to R6 only in the game settings and it was fixed. Thanks for the help, the video was very helpful!

    • @Fexxies
      @Fexxies Před 15 dny

      @@CritDEV Hi, I'm trying to make a zombie game, but something isn't working right with your model. It turns out that I have a killer and I change the name "Humanoid" to "Zombie" and it doesn't work. Could you help me please?

    • @CritDEV
      @CritDEV  Před 15 dny

      @@Fexxies do not rename the Humanoid, i believe the property you are looking to change inside of the humanoid is called DisplayName
      edit: even if this is not what you are trying to do, you should not have to rename the humanoid under any circumstance. please join the discord if you need help.

  • @margwa_slayer2972
    @margwa_slayer2972 Před 11 měsíci

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

  • @user-ew6co3bm1b
    @user-ew6co3bm1b Před 7 měsíci

    It’s not working for me

  • @zombie_gamer2122
    @zombie_gamer2122 Před měsícem

    Literally nothing works for me.

    • @CritDEV
      @CritDEV  Před měsícem

      @@zombie_gamer2122 Please send a code sample.

  • @firedragon7891
    @firedragon7891 Před 6 měsíci

    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  Před 6 měsíci

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

    • @firedragon7891
      @firedragon7891 Před 6 měsíci

      @@CritDEV ok thx i will try this tomorrow

  • @left2841
    @left2841 Před 8 měsíci

    it doesn't work

  • @42N4K
    @42N4K Před 2 měsíci

    how can you make it chase the nearest player?

    • @CritDEV
      @CritDEV  Před 2 měsíci

      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.

  • @taywanjesuper5954
    @taywanjesuper5954 Před 7 měsíci

    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  Před 7 měsíci +1

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

    • @taywanjesuper5954
      @taywanjesuper5954 Před 7 měsíci

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

  • @Ayenisko
    @Ayenisko Před měsícem +1

    I don’t understand it

    • @CritDEV
      @CritDEV  Před měsícem

      Please tell me what confuses you so I can help.

    • @Ayenisko
      @Ayenisko Před měsícem

      @@CritDEV Om new to developing

  • @RoyaItee
    @RoyaItee Před 9 měsíci

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

    • @CritDEV
      @CritDEV  Před 9 měsíci

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

    • @RoyaItee
      @RoyaItee Před 9 měsíci

      @@CritDEV Okay! Thanks.

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 Před rokem

    how do I make my npc jump

  • @DarkThePurple
    @DarkThePurple Před 10 měsíci

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

    • @CritDEV
      @CritDEV  Před 10 měsíci

      Yeah I think thats a Roblox feature for the Pathfinding Service

  • @animebinger7974
    @animebinger7974 Před 8 měsíci

    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  Před 8 měsíci

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

    • @animebinger7974
      @animebinger7974 Před 8 měsíci

      @@CritDEV Holy crap ty!

    • @CritDEV
      @CritDEV  Před 8 měsíci

      @@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 Před 8 měsíci

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

  • @RobloxFrogger
    @RobloxFrogger Před 29 dny

    The script won't work with a mesh, would it?

    • @CritDEV
      @CritDEV  Před 28 dny +1

      It will as long as it has a Humanoid and a HumanoidRootPart

    • @RobloxFrogger
      @RobloxFrogger Před 27 dny

      @@CritDEV alright, thank you (:

  • @timmypack
    @timmypack Před měsícem

    Im boura try this ill lyk if it works

  • @0_0fakei18
    @0_0fakei18 Před 7 měsíci

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

    • @CritDEV
      @CritDEV  Před 7 měsíci

      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 Před 7 měsíci

      @@CritDEV thank you

  • @фута
    @фута Před 4 měsíci

    just tried on my game, rly badly calculates paths

    • @CritDEV
      @CritDEV  Před 4 měsíci

      Is Roblox’s pathfinding mechanism…

    • @CritDEV
      @CritDEV  Před 4 měsíci

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

  • @avidyoutubewatcher1897
    @avidyoutubewatcher1897 Před rokem +1

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

    • @CritDEV
      @CritDEV  Před rokem

      Walkspeed of the humanoid

    • @avidyoutubewatcher1897
      @avidyoutubewatcher1897 Před rokem

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

    • @avidyoutubewatcher1897
      @avidyoutubewatcher1897 Před rokem

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

    • @CritDEV
      @CritDEV  Před rokem

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

  • @seklerne
    @seklerne Před 4 měsíci

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

    • @CritDEV
      @CritDEV  Před 4 měsíci

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

    • @seklerne
      @seklerne Před 4 měsíci

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

  • @chosenone3
    @chosenone3 Před měsícem +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  Před měsícem

      Can you send the call you used ?

    • @CritDEV
      @CritDEV  Před měsícem

      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 Před měsícem +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  Před měsícem

      @@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 Před měsícem +1

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

  • @omittingsteveyt3466
    @omittingsteveyt3466 Před rokem +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})

  • @vicstorm1079
    @vicstorm1079 Před 16 dny

    epic

  • @40_ton55
    @40_ton55 Před měsícem

    Could this be used with aircraft?

    • @CritDEV
      @CritDEV  Před měsícem

      @@40_ton55 probably not.

  • @therandomgamermonkey6259

    Yay I can make a horror game

  • @fv2536
    @fv2536 Před 10 měsíci

    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  Před 10 měsíci

      Make sure you did require(ai)

    • @fv2536
      @fv2536 Před 10 měsíci

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

    • @fv2536
      @fv2536 Před 10 měsíci

      @@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  Před 10 měsíci

      @@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 Před 10 měsíci

      @@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?

  • @Itchingasscheeks420
    @Itchingasscheeks420 Před 5 měsíci

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

    • @CritDEV
      @CritDEV  Před 5 měsíci

      Turn on visualize

    • @Itchingasscheeks420
      @Itchingasscheeks420 Před 5 měsíci

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

    • @CritDEV
      @CritDEV  Před 5 měsíci

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

  • @JRAplayzstuffs
    @JRAplayzstuffs Před 3 dny

    didnt work,

    • @CritDEV
      @CritDEV  Před 3 dny

      @@JRAplayzstuffs Please provide information or join the discord

  • @yousefsaleh3562
    @yousefsaleh3562 Před 8 měsíci

    Is this good performance-wise?

    • @CritDEV
      @CritDEV  Před 8 měsíci

      Tracking is not. Otherwise, it is

  • @masterwallace4268
    @masterwallace4268 Před rokem +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 czcams.com/video/ec6feocxMhA/video.html

    • @masterwallace4268
      @masterwallace4268 Před rokem

      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

  • @SuperAngel2384
    @SuperAngel2384 Před 11 měsíci +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?

    • @Alex10RBLX
      @Alex10RBLX Před 8 měsíci +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)

    • @Alex10RBLX
      @Alex10RBLX Před 8 měsíci +1

      btw all this code is mine

    • @Alex10RBLX
      @Alex10RBLX Před 8 měsíci +1

      except forbidden api :]

  • @nothing2e12as
    @nothing2e12as Před 7 měsíci

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

    • @CritDEV
      @CritDEV  Před 7 měsíci

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

    • @nothing2e12as
      @nothing2e12as Před 7 měsíci

      @@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

  • @CapybaraGamingPC
    @CapybaraGamingPC Před rokem

    how do i make the npc jum

    • @CritDEV
      @CritDEV  Před rokem +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

  • @helloneighborsmosh806
    @helloneighborsmosh806 Před 9 měsíci

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

    • @CritDEV
      @CritDEV  Před 9 měsíci +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 Před 9 měsíci

      @@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  Před 9 měsíci

      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

  • @jellyii8886
    @jellyii8886 Před 8 měsíci

    What would happen if there is no path available?

    • @CritDEV
      @CritDEV  Před 8 měsíci +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  Před 8 měsíci +1

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

    • @jellyii8886
      @jellyii8886 Před 8 měsíci

      Thank you!@@CritDEV

  • @THE_GOLDENSPECTRA
    @THE_GOLDENSPECTRA Před měsícem

    Why doesn’t not work😢

    • @CritDEV
      @CritDEV  Před měsícem

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

    • @THE_GOLDENSPECTRA
      @THE_GOLDENSPECTRA Před měsícem

      @@CritDEV ok

  • @user-ud7zt5dt31
    @user-ud7zt5dt31 Před 9 měsíci

    how to set max chase distance?

  • @persona8614
    @persona8614 Před rokem +1

    doesnt work did all you did

    • @CritDEV
      @CritDEV  Před rokem

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

    • @Psygenz
      @Psygenz Před rokem

      @@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  Před rokem

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

    • @Psygenz
      @Psygenz Před rokem

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

    • @Psygenz
      @Psygenz Před rokem

      @@CritDEV 👍

  • @пхпх
    @пхпх Před 3 měsíci

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

    • @CritDEV
      @CritDEV  Před 3 měsíci

      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 Před 8 měsíci

    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  Před 8 měsíci +1

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

    • @fitmotheyap
      @fitmotheyap Před měsícem

      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 Před 6 měsíci

    too laggy

    • @CritDEV
      @CritDEV  Před 6 měsíci

      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 Před 6 měsíci

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

    • @CritDEV
      @CritDEV  Před 6 měsíci

      @@juhmop Not with tracking enabled.

  • @Fastboy_Gaming
    @Fastboy_Gaming Před 7 měsíci +1

    Learn to code better

  • @Tnt0322
    @Tnt0322 Před rokem

    is there a way to contact you? discord etc.

    • @CritDEV
      @CritDEV  Před rokem

      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