How to PATHFIND in Roblox 2024 using Forbidden

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ต.ค. 2024

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

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

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

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

      It is forbidden to unsubscribe to you

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

      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  10 หลายเดือนก่อน +2

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

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

      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  8 หลายเดือนก่อน +1

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

  • @patriot7260
    @patriot7260 9 หลายเดือนก่อน +14

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

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

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

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

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

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

    I came here by watching yt shorts

    • @zaydtruck3496
      @zaydtruck3496 11 หลายเดือนก่อน +2

      Same

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

      Bawls same!

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

      Sqme

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

      Same

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

      Same

  • @turbs1348
    @turbs1348 9 หลายเดือนก่อน +4

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

  • @hutcle
    @hutcle 9 หลายเดือนก่อน +4

    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

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

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

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

    very cool lookin forward to updates

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

    THIS MAN IS HEAVILY UNDERRATED!

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

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

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

    This was so helpful tysm 😭

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

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

    • @Daber-wh5ug
      @Daber-wh5ug ปีที่แล้ว

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

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

    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

  • @YoungBassAngler
    @YoungBassAngler ปีที่แล้ว +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  ปีที่แล้ว +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 ปีที่แล้ว

      Alright. Again, I really appreciate it
      @@CritDEV

    • @JJsStuff
      @JJsStuff ปีที่แล้ว +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 10 หลายเดือนก่อน

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

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

  • @Daber-wh5ug
    @Daber-wh5ug ปีที่แล้ว +3

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

    • @Mr_guy-RBLX
      @Mr_guy-RBLX 2 หลายเดือนก่อน

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

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

    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  8 หลายเดือนก่อน +1

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

    • @CritDEV
      @CritDEV  8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

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

  • @voxiic.
    @voxiic. 6 วันที่ผ่านมา +1

    does this work to make a car pathfind to an object and repeat driviing around the map? I really want to make a car drive around the map on roads so i hope this model can do that. a tut would be nice pls.

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

      No, and unfortunately I cannot make a tutorial.
      My recommendation would be to use the pathfinding API from roblox and use tweens and lerps to move the car.

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

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

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

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

  • @patata8457
    @patata8457 ปีที่แล้ว +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 ปีที่แล้ว +1

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

  • @DomExists
    @DomExists ปีที่แล้ว +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?

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

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

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

    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  8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@CritDEV Thx

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

      @@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  8 หลายเดือนก่อน

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

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

      @@CritDEV okay

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

    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  ปีที่แล้ว +1

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

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

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

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

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

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

      @@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 10 หลายเดือนก่อน

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

  • @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 8 หลายเดือนก่อน

      @@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  8 หลายเดือนก่อน

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

  • @Necicam
    @Necicam ปีที่แล้ว +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})

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

      Not all heros wear capes💯💯

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

      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

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

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

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

    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

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

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

  • @the-notorious-khaki
    @the-notorious-khaki ปีที่แล้ว +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  ปีที่แล้ว +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

    • @the-notorious-khaki
      @the-notorious-khaki ปีที่แล้ว

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

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

    Can you make it so it only see a player and tracks him down if he is in sight and not behind a wall for example?

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

      @@OhHaiC go to the Chase AI video on my channel for the premade solution.
      By default it does that

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

      @@CritDEVIs it the ray cast fov video?

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

      Oh yeah, also thanks for the ai module man. I'm not really a fan of free models but I'm starting to like module scripts. They spare a lot of time and you still need to do the stuff.
      Like, you have the pathfinding script and everything, but you still need to code the behavior of your ai, it's very customizable and I'm loving it, thank you for your service! I'll make sure to credit your work in my game :)

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

      @@OhHaiC yeah you can use that if you want to create the AI yourself. ChaseAI I would look into to see if it does what you need.

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

      @@CritDEV I can't seem to find the chase ai video that you're talking about
      But anyways I think I can achieve similar results with the raycast fov video you made. You get all of the players, check if one of them is inside the ai specified range. Then, check if the player humanoid root part (or whatever part you assign in the script) is in range of the ai fov. If it is, then start chasing the player.

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

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

    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  9 หลายเดือนก่อน

      Simply get player.Character.Humanoid.Health

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

  • @stanciooliver2745
    @stanciooliver2745 ปีที่แล้ว +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  ปีที่แล้ว

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

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

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

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

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

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

      @@CritDEV Anyways, it's working now.

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

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

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

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

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

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

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

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

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

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

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

      @@CritDEV Okay! Thanks.

  • @Dave-r1j
    @Dave-r1j 24 วันที่ผ่านมา

    i did exactly what you did but it doesnt work. my dummy stay on the place and do nothing

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

      @@Dave-r1j join discord for support or message errors

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

    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  8 หลายเดือนก่อน

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

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

      @@CritDEV ok thx i will try this tomorrow

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

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

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

      You are passing an object or thing that no longer exists

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

    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  หลายเดือนก่อน

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

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

      @@CritDEV thank you

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

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

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

    Mine just flat out doesnt work at all

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

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

    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  9 หลายเดือนก่อน +1

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

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

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

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

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

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

      Yeah I think thats a Roblox feature for the Pathfinding Service

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

    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  หลายเดือนก่อน

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

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

      @@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 หลายเดือนก่อน

      @@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  หลายเดือนก่อน

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

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

    didn't work for me.

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

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

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

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

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

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

  • @Blockhead743
    @Blockhead743 10 วันที่ผ่านมา

    In your short you said only one line of code but there is definite more than one line

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

      @@Blockhead743 it’s one line of code. It’s just best practice not to make it one line and abstract your variables like the module, NPC, and target.

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

    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  11 หลายเดือนก่อน

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

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

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

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

      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 9 หลายเดือนก่อน

      @@CritDEV thank you

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

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

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

      Set tracking to true

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

      @@CritDEV thx

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

    Full of bugs when It requires jumping

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

    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  2 หลายเดือนก่อน

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

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

      @@CritDEV I don't have discord.

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

      @@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 2 หลายเดือนก่อน +1

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

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

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

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

      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

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

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

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

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

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

      @@CritDEV alright, thank you (:

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

    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  10 หลายเดือนก่อน

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

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

      @@CritDEV Holy crap ty!

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

      @@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 10 หลายเดือนก่อน

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

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

    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  9 หลายเดือนก่อน

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

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

    How do you make it so it is speeder than the player ? how do you change the walkspeed?

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

      @@SuperFenix164 change the WalkSpeed inside the Humanoid of the NPC

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

      @@CritDEV oh i know i tried that but it is changing the walk speed but i think it stops for like 2 ms because i checked and the walk speed didn't change. How can i change it so it doesen't stop and reach the player?

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

      @@SuperFenix164 well that is how it should work. Just to make sure there is no other script running? Nothing like the ChaseAI module or anything ?

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

      @@CritDEV i checked and nothing else is running

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

      @@CritDEV oh sorry im just dumb i didn't know that it was touching me because i didn't setup the kill script

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

    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  11 หลายเดือนก่อน

      Make sure you did require(ai)

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

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

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

      @@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  11 หลายเดือนก่อน

      @@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 11 หลายเดือนก่อน

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

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

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

    my npc is not moving i dont know what to do

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

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

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

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

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

    the script does not workkkk

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

    what if you change it with a diffirent monster

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

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

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

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

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

    Is this good performance-wise?

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

      Tracking is not. Otherwise, it is

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

    it doesn't work

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

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

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

      Walkspeed of the humanoid

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

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

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

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

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

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

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

    how can you make it chase the nearest player?

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

      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.

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

    it doesnt work for me

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

    is it possible to use this for a tower defense
    game

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

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

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

      @@CritDEV ok thanks

  • @SuperAngel2384
    @SuperAngel2384 ปีที่แล้ว +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?

    • @Generic-Alex
      @Generic-Alex 10 หลายเดือนก่อน +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)

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

      btw all this code is mine

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

      except forbidden api :]

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

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

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

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

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

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

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

    Literally nothing works for me.

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

      @@zombie_gamer2122 Please send a code sample.

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

    StandardPathfindSettings, what is it.

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

    When I download this the file is empty

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

      please make sure you have gone to the link in the description.
      I have checked, the file is there.

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

    just tried on my game, rly badly calculates paths

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

      Is Roblox’s pathfinding mechanism…

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

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

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

    What would happen if there is no path available?

    • @CritDEV
      @CritDEV  9 หลายเดือนก่อน +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  9 หลายเดือนก่อน +1

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

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

      Thank you!@@CritDEV

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

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

    • @CritDEV
      @CritDEV  11 หลายเดือนก่อน +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 11 หลายเดือนก่อน

      @@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  11 หลายเดือนก่อน

      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

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

    how do I make my npc jump

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

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

    550 subscriber❤

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

    how to set max chase distance?

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

      Range of pathfind in settings

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

      AgentRadius?

  • @Ayenisko
    @Ayenisko 2 หลายเดือนก่อน +1

    I don’t understand it

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

      Please tell me what confuses you so I can help.

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

      @@CritDEV Om new to developing

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

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

    Why doesn’t not work😢

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

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

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

      @@CritDEV ok

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

    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  9 หลายเดือนก่อน +1

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

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

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

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

    didnt work,

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

      @@JRAplayzstuffs Please provide information or join the discord

  • @chosenone3
    @chosenone3 2 หลายเดือนก่อน +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  2 หลายเดือนก่อน

      Can you send the call you used ?

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

      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 2 หลายเดือนก่อน +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  2 หลายเดือนก่อน

      @@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 2 หลายเดือนก่อน +1

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

  • @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 ปีที่แล้ว

      @@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 ปีที่แล้ว

      You're a life saver

    • @Enigmatic-v83
      @Enigmatic-v83 ปีที่แล้ว

      bro is a lifesaver

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

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

    epic

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

  • @NotFakerMiddle
    @NotFakerMiddle 25 วันที่ผ่านมา

    your not even explaining. your confusing me so much.

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

      @@NotFakerMiddle Most people understand. If you are new to coding you may not.

    • @NotFakerMiddle
      @NotFakerMiddle 25 วันที่ผ่านมา

      @@CritDEV no, I understand coding, I just didn’t understand where to put the scripts, you said to put it in replicated storage, but what about the NPC?

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

      @@NotFakerMiddle You create a script as shown in the video. For more, you can join the discord in the video description.

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

    Yay I can make a horror game