How to PATHFIND in Roblox 2024 using Forbidden

Поделиться
HTML-код
  • Опубликовано: 5 мар 2023
  • Link to API: www.roblox.com/library/112294...
    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.
    API.Stop() will be patched hopefully by tomorrow.
    Please comment with your game's name/link if you use Forbidden and good luck!
    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
  • ИгрыИгры

Комментарии • 237

  • @CritixxDEV
    @CritixxDEV  Год назад +11

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

    • @ConeParty
      @ConeParty 9 месяцев назад

      It is forbidden to unsubscribe to you

    • @HeroDevv
      @HeroDevv 6 месяцев назад +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?

    • @CritixxDEV
      @CritixxDEV  6 месяцев назад +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.

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

  • @aspirin4279
    @aspirin4279 Год назад +31

    I came here by watching yt shorts

  • @patriot7260
    @patriot7260 6 месяцев назад +3

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

  • @soundsofjupiter2859
    @soundsofjupiter2859 Год назад +5

    very cool lookin forward to updates

  • @hutcle
    @hutcle 6 месяцев назад +1

    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 5 месяцев назад +1

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

  • @Sugar._.Stxrrr
    @Sugar._.Stxrrr Месяц назад +1

    This was so helpful tysm 😭

  • @CopyStudiosFilms
    @CopyStudiosFilms 8 месяцев назад +2

    THIS MAN IS HEAVILY UNDERRATED!

  • @taywanjesuper5954
    @taywanjesuper5954 5 месяцев назад

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

  • @galvanygames1441
    @galvanygames1441 11 месяцев назад +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?

  • @Yuilix
    @Yuilix 8 дней назад

    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

  • @masterwallace4268
    @masterwallace4268 11 месяцев назад +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 ruclips.net/video/ec6feocxMhA/видео.html

    • @masterwallace4268
      @masterwallace4268 11 месяцев назад

      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

  • @Ismail_NotFullName
    @Ismail_NotFullName 5 месяцев назад

    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

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

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

    • @CritixxDEV
      @CritixxDEV  Год назад

      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!

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

    • @JJsStuff
      @JJsStuff 10 месяцев назад +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 6 месяцев назад

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

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

  • @sinnickle4357
    @sinnickle4357 Месяц назад

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

  • @Daber-wh5ug
    @Daber-wh5ug 11 месяцев назад +2

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

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

    • @CritixxDEV
      @CritixxDEV  Год назад

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

  • @Jagrio
    @Jagrio 11 месяцев назад +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 11 месяцев назад

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

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 11 месяцев назад +1

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

    • @jamesmcgillivray6741
      @jamesmcgillivray6741 11 месяцев назад

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

  • @BlankJuice
    @BlankJuice 5 месяцев назад

    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

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

      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 5 месяцев назад

      @@CritixxDEV Thx

    • @BlankJuice
      @BlankJuice 5 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

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

    • @BlankJuice
      @BlankJuice 5 месяцев назад

      @@CritixxDEV okay

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

  • @HaileyStudios1213
    @HaileyStudios1213 3 месяца назад

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

  • @f3n532
    @f3n532 3 месяца назад

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

  • @weirdsweapons
    @weirdsweapons 10 месяцев назад +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.

    • @CritixxDEV
      @CritixxDEV  10 месяцев назад +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 10 месяцев назад

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

  • @matt9559
    @matt9559 11 месяцев назад +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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

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

    • @matt9559
      @matt9559 11 месяцев назад +1

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

    • @AdvancedAnimator
      @AdvancedAnimator 5 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

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

  • @bacony12bruh
    @bacony12bruh 5 месяцев назад

    550 subscriber❤

  • @JustArealfr
    @JustArealfr 3 месяца назад

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

  • @stanciooliver2745
    @stanciooliver2745 9 месяцев назад +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

    • @CritixxDEV
      @CritixxDEV  9 месяцев назад

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

    • @Cocodado
      @Cocodado 9 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  9 месяцев назад

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

    • @Cocodado
      @Cocodado 9 месяцев назад

      @@CritixxDEV Anyways, it's working now.

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

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад +1

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

    • @CritixxDEV
      @CritixxDEV  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 месяцев назад

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

  • @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 17 дней назад

      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

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

    • @CritixxDEV
      @CritixxDEV  6 месяцев назад

      Simply get player.Character.Humanoid.Health

  • @AlexiscoPlays
    @AlexiscoPlays Год назад +1

    didn't work for me.

  • @patata8457
    @patata8457 10 месяцев назад +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 10 месяцев назад +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

  • @F7RBeast
    @F7RBeast 8 месяцев назад

    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

    • @CritixxDEV
      @CritixxDEV  8 месяцев назад +1

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

    • @F7RBeast
      @F7RBeast 8 месяцев назад

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

    • @Royal23458
      @Royal23458 7 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  7 месяцев назад

      @@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 7 месяцев назад

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

  • @0KIT0771
    @0KIT0771 Год назад

    my npc is not moving i dont know what to do

  • @masterwallace4268
    @masterwallace4268 11 месяцев назад +1

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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

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

    • @masterwallace4268
      @masterwallace4268 11 месяцев назад +1

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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

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

    • @badprong2556
      @badprong2556 11 месяцев назад

      @@CritixxDEV yo does this work on r6 models?

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

      @@badprong2556 should

  • @soohyuk77
    @soohyuk77 6 месяцев назад

    i updated to 0.0.4 and its really laggy than 0.0.3
    the bots are using tracking mode and walkspeed is 60

    • @CritixxDEV
      @CritixxDEV  6 месяцев назад

      Use setnetworkowner

  • @Lennypennyez
    @Lennypennyez 11 месяцев назад +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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

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

    • @Lennypennyez
      @Lennypennyez 11 месяцев назад

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

  • @suikapuffin
    @suikapuffin 2 месяца назад

    StandardPathfindSettings, what is it.

  • @keshido1
    @keshido1 3 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

      You are passing an object or thing that no longer exists

  • @firedragon7891
    @firedragon7891 4 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  4 месяца назад

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

    • @firedragon7891
      @firedragon7891 4 месяца назад

      @@CritixxDEV ok thx i will try this tomorrow

  • @Royal23458
    @Royal23458 7 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  7 месяцев назад

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

    • @Royal23458
      @Royal23458 7 месяцев назад

      @@CritixxDEV Okay! Thanks.

  • @margwa_slayer2972
    @margwa_slayer2972 9 месяцев назад

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

  • @jamesmcgillivray6741
    @jamesmcgillivray6741 Год назад

    how do I make my npc jump

  • @keshido1
    @keshido1 3 месяца назад

    the script does not workkkk

  • @yousefsaleh3562
    @yousefsaleh3562 7 месяцев назад

    Full of bugs when It requires jumping

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

    • @CritixxDEV
      @CritixxDEV  7 месяцев назад

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

    • @animebinger7974
      @animebinger7974 7 месяцев назад

      @@CritixxDEV Holy crap ty!

    • @CritixxDEV
      @CritixxDEV  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 месяцев назад

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

  • @cladaigh
    @cladaigh 8 месяцев назад

    it doesnt work for me

  • @user-ew6co3bm1b
    @user-ew6co3bm1b 5 месяцев назад

    It’s not working for me

  • @Stefan_IC
    @Stefan_IC Год назад +1

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

    • @CritixxDEV
      @CritixxDEV  Год назад +1

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

  • @dogeball2628
    @dogeball2628 2 месяца назад

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

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

  • @doctext-jose.e-3484
    @doctext-jose.e-3484 8 месяцев назад

    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

    • @CritixxDEV
      @CritixxDEV  8 месяцев назад

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

  • @timjitz2708
    @timjitz2708 11 месяцев назад +1

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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад +1

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

    • @timjitz2708
      @timjitz2708 11 месяцев назад

      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.

  • @taywanjesuper5954
    @taywanjesuper5954 5 месяцев назад

    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?

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад +1

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

    • @taywanjesuper5954
      @taywanjesuper5954 5 месяцев назад

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

  • @DarkThePurple
    @DarkThePurple 8 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  8 месяцев назад

      Yeah I think thats a Roblox feature for the Pathfinding Service

  • @fv2536
    @fv2536 8 месяцев назад

    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

    • @CritixxDEV
      @CritixxDEV  8 месяцев назад

      Make sure you did require(ai)

    • @fv2536
      @fv2536 8 месяцев назад

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

    • @fv2536
      @fv2536 8 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  8 месяцев назад

      @@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 8 месяцев назад

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

  • @left2841
    @left2841 6 месяцев назад

    it doesn't work

  • @Rkyiel
    @Rkyiel 24 дня назад

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

    • @CritixxDEV
      @CritixxDEV  24 дня назад

      Set tracking to true

    • @Rkyiel
      @Rkyiel 24 дня назад

      @@CritixxDEV thx

  • @Neqkoo
    @Neqkoo 3 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

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

  • @0_0fakei18
    @0_0fakei18 5 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

      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 5 месяцев назад

      @@CritixxDEV thank you

  • @seklerne
    @seklerne 2 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  2 месяца назад

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

    • @seklerne
      @seklerne 2 месяца назад

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

  • @yousefsaleh3562
    @yousefsaleh3562 7 месяцев назад

    Is this good performance-wise?

    • @CritixxDEV
      @CritixxDEV  7 месяцев назад

      Tracking is not. Otherwise, it is

  • @therandomgamermonkey6259
    @therandomgamermonkey6259 Год назад

    Yay I can make a horror game

  • @avidyoutubewatcher1897
    @avidyoutubewatcher1897 11 месяцев назад +1

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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

      Walkspeed of the humanoid

    • @avidyoutubewatcher1897
      @avidyoutubewatcher1897 11 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  11 месяцев назад

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

  • @42N4K
    @42N4K 20 дней назад

    how can you make it chase the nearest player?

    • @CritixxDEV
      @CritixxDEV  16 дней назад

      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 ?

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

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

    • @nothing2e12as
      @nothing2e12as 5 месяцев назад

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

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

    • @AlexGT_alt
      @AlexGT_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)

    • @AlexGT_alt
      @AlexGT_alt 7 месяцев назад +1

      btw all this code is mine

    • @AlexGT_alt
      @AlexGT_alt 7 месяцев назад +1

      except forbidden api :]

  • @helloneighborsmosh806
    @helloneighborsmosh806 8 месяцев назад

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

    • @CritixxDEV
      @CritixxDEV  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 месяцев назад

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

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

  • @jellyii8886
    @jellyii8886 6 месяцев назад

    What would happen if there is no path available?

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

    • @CritixxDEV
      @CritixxDEV  6 месяцев назад +1

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

    • @jellyii8886
      @jellyii8886 6 месяцев назад

      Thank you!@@CritixxDEV

  • @40_ton55
    @40_ton55 3 дня назад

    Could this be used with aircraft?

  • @фута
    @фута 3 месяца назад

    just tried on my game, rly badly calculates paths

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

      Is Roblox’s pathfinding mechanism…

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

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

  • @CapybaraGamingPC
    @CapybaraGamingPC Год назад

    how do i make the npc jum

    • @CritixxDEV
      @CritixxDEV  Год назад +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

  • @rattle_dash
    @rattle_dash 5 месяцев назад

    is it possible to use this for a tower defense
    game

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

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

    • @rattle_dash
      @rattle_dash 5 месяцев назад

      @@CritixxDEV ok thanks

  • @DarkestGames86
    @DarkestGames86 5 месяцев назад

    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)

    • @CritixxDEV
      @CritixxDEV  5 месяцев назад

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

  • @numberoneshiteater
    @numberoneshiteater 3 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

      Turn on visualize

    • @numberoneshiteater
      @numberoneshiteater 3 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  3 месяца назад

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

  • @user-ud7zt5dt31
    @user-ud7zt5dt31 7 месяцев назад

    how to set max chase distance?

  • @omittingsteveyt3466
    @omittingsteveyt3466 11 месяцев назад +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})

  • @persona8614
    @persona8614 Год назад +1

    doesnt work did all you did

    • @CritixxDEV
      @CritixxDEV  Год назад

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

    • @Psygenz
      @Psygenz Год назад

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

    • @CritixxDEV
      @CritixxDEV  Год назад

      @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 Год назад

      @@CritixxDEV 👍

  • @juhmop
    @juhmop 4 месяца назад

    too laggy

    • @CritixxDEV
      @CritixxDEV  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 месяца назад

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

    • @CritixxDEV
      @CritixxDEV  4 месяца назад

      @@juhmop Not with tracking enabled.

  • @пхпх
    @пхпх Месяц назад

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

    • @CritixxDEV
      @CritixxDEV  Месяц назад

      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!

    • @CritixxDEV
      @CritixxDEV  6 месяцев назад +1

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

  • @Fastboy_Gaming
    @Fastboy_Gaming 6 месяцев назад +1

    Learn to code better

  • @Tnt0322
    @Tnt0322 11 месяцев назад

    is there a way to contact you? discord etc.

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