Advanced Roblox Scripting Tutorial #21 - Pathfinding (Beginner to Pro 2019)

Поділитися
Вставка
  • Опубліковано 1 чер 2024
  • Advanced Roblox Scripting Tutorial #21 - Pathfinding (Beginner to Pro 2019)
    Hey guys! Welcome back to a brand new roblox scripting tutorial. In today's video I am going to be teaching you about pathfinding / pathfinding service. This is an insanely fun but important topic and I'm so excited to show you guys! If you have any questions like always leave them in the comments. Enjoy :)
    Character Loading Plugin: www.roblox.com/library/752585...
    -- Follow me on twitter! (my name is tapwater because thats my main channel): / realtapwater
    -- Follow me on Instagram! (my name is tapwater because of my main channel): / realtapwater
    - Join my Discord Server to learn and meet other developers!-
    / discord
    Link to Beginner's Tutorial Series:
    • Beginner's Roblox Scri...
    --What is this series about and who is it for?
    So this series is meant for people who really want to learn exactly how to script, if that is you then I promise by the time you watch this whole series you will know exactly how to script on roblox. Anyways be sure to subscribe to see whenever I release a new tutorial and I will see you guys in the next one. Peace!

КОМЕНТАРІ • 971

  • @TheDevKing
    @TheDevKing  4 роки тому +101

    Hey guys! I'm planning on uploading a lot more and I'm really excited for the future of this channel. Be sure to join the discord server to stay connected, meet other devs, and learn!: discord.gg/FKcSyRh

    • @chickenoodle3397
      @chickenoodle3397 4 роки тому +3

      I'd love a tutorial on Mesh Deformation it'll be kind of complicated though.

    • @potatozef
      @potatozef 4 роки тому +2

      I like ur vids

    • @TheDevKing
      @TheDevKing  4 роки тому +4

      thanks :)

    • @leoskits5982
      @leoskits5982 4 роки тому

      once the NPC has reached one part, how do I make him move to another part and then loop that so he keeps walking like that?

    • @alieppey9555
      @alieppey9555 4 роки тому +1

      Can I make a game with u

  • @MarkoBrainz
    @MarkoBrainz 3 роки тому +62

    7:20 "It's gonna get stuck on the wall - cuz it has *no brain* "
    Poor NPC ;c

  • @axmist7189
    @axmist7189 4 роки тому +163

    20:25 Have captions on lmao

    • @rufodeer5421
      @rufodeer5421 4 роки тому +34

      "stripping tutorial... im serious im gonna do some sex criminals"

    • @mytholis7416
      @mytholis7416 4 роки тому +2

      lmao

    • @cooperknows5627
      @cooperknows5627 4 роки тому +17

      20:47 “laying it in my own baby”

    • @GGGLStudios
      @GGGLStudios 4 роки тому +1

      @@cooperknows5627 lol

    • @lerebox
      @lerebox 4 роки тому +7

      and then it said after the s*x criminal it said sick scripting LOL

  • @shishiirpriyadarshi9
    @shishiirpriyadarshi9 2 місяці тому +2

    Hey @TheDevKing, I really appreciate your scripting tutorials from the past (lol). Before I watched your scripting tutorial for pathfinding, I would be confused because I was quite a new scripter back then. After watching your video, understanding it, and practicing it, I can now make a randomizer for this specific service! Thanks a lot! Hope you make more tutorials like this!

  • @ducky9028
    @ducky9028 3 роки тому +47

    2:25 We're going to use r15 cause it's pretty simple. *deletes r15 model*

  • @IDcLuc
    @IDcLuc Рік тому +3

    i love how when he doesnt know what to say about something he just acts like he never talked about it and just says "you know what i mean anyways"

  • @chickenoodle3397
    @chickenoodle3397 4 роки тому +86

    Perfect i needed this for fire flies thank you so much perfect timing coming in clutch every time

    • @TheDevKing
      @TheDevKing  4 роки тому +17

      Awesome good luck with the flier flies lol

    • @chickenoodle3397
      @chickenoodle3397 4 роки тому +5

      @@TheDevKing it's really hard and i have the script and everything right and its not working i think ima restart lol i'ma keep working on my scripting

    • @chickenoodle3397
      @chickenoodle3397 4 роки тому +3

      @@TheSxrged absolute lad

    • @dobi2447
      @dobi2447 3 роки тому +1

      any1 who thinks hes a mind reading lizard? Anyone?

    • @acurrz4367
      @acurrz4367 2 роки тому

      @@chickenoodle3397 you making a one piece game?

  • @Beij1ngCorn
    @Beij1ngCorn Рік тому +1

    I love your videos, they're funny and useful

  • @PoboyMusic
    @PoboyMusic 4 роки тому

    Thanks for all your vids man.

  • @FiredDanST
    @FiredDanST 4 роки тому +5

    Yooooo. I needed this. Tysm

    • @TheDevKing
      @TheDevKing  4 роки тому +1

      :)

    • @AlguienPromedio
      @AlguienPromedio 3 роки тому

      Why not works in my world? :(

    • @akshitagoel6762
      @akshitagoel6762 3 роки тому

      @@AlguienPromedio For me it said "Infinite yield possible" in the line where i defined the torso. That's because in the later version there is no part called a torso there is either upper torso or lower torso. Hope I helped.

  • @Felipowvisky
    @Felipowvisky 2 роки тому +3

    i finally made an working spins system after 1 week of tutorials on google and youtube, I wouldn't be able to make this if it wasn't for alot of people including you so... THANKS ALOT
    mostly you xD

  • @alve_n.s.f8953
    @alve_n.s.f8953 2 роки тому +1

    Amazing 👏👏👏👏👏
    Keep up The good work! 😀 😀 😀

  • @axmist7189
    @axmist7189 4 роки тому +2

    Tysm this was a useful tutorial!

  • @specificocean588
    @specificocean588 Рік тому +23

    the reason it is "lagging" is because of the wait(2). towards the end the paths were shorter because the npc just had to jump over stuff, so it was taking less than 2 seconds to get to the next waypoint and it had to stop and wait for the 2 seconds to finish.
    Instead you should make it wait until the movetofinished is called

    • @flawlesscode8698
      @flawlesscode8698 Рік тому

      how lol

    • @ImJustNeon
      @ImJustNeon Рік тому

      just remove the number inside the wait()

    • @flawlesscode8698
      @flawlesscode8698 Рік тому +1

      @@ImJustNeon Yeah but think about the lag afterwards, because standart its 0,3s

    • @IcikiwirJava
      @IcikiwirJava 10 місяців тому

      i think task.wait() is way better

    • @thecolorblue7427
      @thecolorblue7427 7 місяців тому

      @@IcikiwirJava task.wait wouldn't work in this case, because what the wait function for the npc is specifically used to wait for until the npc hits the waypoint. That means that it could end up waiting for eternity if it never touches the waypoint, but if it does touch the waypoint, it will stop waiting, and the loop will continue to the next waypoint. Task.wait on the other hand, just waits a set amount of time, whether the npc hits the waypoint or not.

  • @iplaysroblox7646
    @iplaysroblox7646 3 роки тому +3

    Thank you so much, i've been scripting for a while(6 months-ish) and this helped me alot I cannot thank you enough for this

  • @Yo_Bl
    @Yo_Bl 2 роки тому

    This is the clearest tutorial on this I have found! This stuff is great!!! If this doesnt earn a sub from everyone idk what does

  • @rogamer4722
    @rogamer4722 Рік тому +1

    Thank you, this helped a lot!

  • @okeanskiy
    @okeanskiy 4 роки тому +36

    good video!

    • @TheDevKing
      @TheDevKing  4 роки тому +9

      omg, okeanskiy. I've seen your videos man! Thanks a lot. Keep up the great work as well! :)

    • @eleos5
      @eleos5 4 роки тому +2

      Its almost as if you made it...

    • @nhanif362
      @nhanif362 3 роки тому

      @@TheDevKingHello

    • @waterhd1834
      @waterhd1834 3 роки тому +1

      @@TheDevKing really said omg and hes verified lol (no hate)

  • @Voided2
    @Voided2 2 роки тому

    THANKKK YOU MAN I FINALLY KNOW HOW TO USE PATHFINDING!!!

  • @asrtrifecta4765
    @asrtrifecta4765 Рік тому

    hey thanks so much! i figured out how to make my character go back and forth between two parts!

  • @destiny4534
    @destiny4534 4 роки тому +58

    20:30 this is the story of sent_cons

  • @SnortingPig88
    @SnortingPig88 Рік тому +7

    For all of you confused , 1) You have to type local torso = script.Parent:WaitForChild("UpperTorso") for r15 2) if your rig is still not moving, make sure the humanoid root part isn't anchored

    • @ReallyPieThings
      @ReallyPieThings Рік тому

      Thank you

    • @Woqdi
      @Woqdi 11 місяців тому

      Thank you so much for help!

    • @GalaxinTM
      @GalaxinTM 9 місяців тому

      alternatively set the torso variable to humanoidrootpart

    • @SnortingPig88
      @SnortingPig88 9 місяців тому

      @@GalaxinTM you could, but for the script in the video i suggest following what i said

  • @vplayz2101
    @vplayz2101 11 місяців тому +2

    If you are doing it with an R15 character, replace the torso with the "HumanoidRootPart"

  • @garyplays2017
    @garyplays2017 3 роки тому

    i like ur tutorials alot bcs u explain everything step-by-step

  • @kennethha8173
    @kennethha8173 2 роки тому +3

    when you do this on a r15 rig, make sure that you have the HumanoidRootPart unanchored otherwise the character won't move.

  • @Food4Cats
    @Food4Cats 5 місяців тому +4

    If you want to have the path constantly update and overcome newly placed obstacles which weren't calculated by the previous path, recalculate the path in a while loop until the character reaches the finish position!

    • @CoiledGravity
      @CoiledGravity 3 місяці тому +1

      how does one do this? ive been trying to do it

    • @dinoguy8052
      @dinoguy8052 11 днів тому

      how does one do this? ive been trying to do it

  • @littlepunkxdlol6081
    @littlepunkxdlol6081 3 роки тому

    Thank you dude!
    + subscriber

  • @yreyuikilop1259
    @yreyuikilop1259 Місяць тому +2

    at the very end, you can use task.wait(2s) and then part:Destroy(), so that way it won't make too much parts on ur workspace

  • @fxnlxn
    @fxnlxn 2 роки тому +10

    Fun thing to do: Make lots of them with the pathfinding script. Put the endingpart inside the region3 from the tutorial a bit back. Where when found inside they die :)

  • @themanpro9075
    @themanpro9075 Рік тому +6

    If you want the npc to go to one point then to another all you have to do is after finishing the script go down 1 and write wait(1) then copy and paste the first part under the wait(1) and change ending part to the name of the other part

    • @AlternativeEsportsYT
      @AlternativeEsportsYT Рік тому +1

      Thanks you're a life saver! :D

    • @liamrileyborres
      @liamrileyborres Рік тому

      could u explain a bit further? like what parts exactly do I change and keep and paste. Thanks

    • @liamrileyborres
      @liamrileyborres Рік тому

      nvm I managed to do it on my own, I just did this after the main script:
      wait()
      human.MoveToFinished:Wait()
      human:MoveTo(game.Workspace.Goal2.Position)

    • @liamrileyborres
      @liamrileyborres Рік тому

      if anyone wants me to paste my whole script then just ask (I didnt add the zombie stuff)

    • @RYAN-6000
      @RYAN-6000 8 місяців тому +2

      ​@@liamrileyborreshi can you paste it even though it's been a month

  • @TheWhiteDaffodils
    @TheWhiteDaffodils 4 роки тому +2

    If u guys are making an npc that shoots u but stays further away, well what u gotta do when the npc s searching for the player, turn the pathfinding on, the when npc is close enough, turn it off. Simple!

  • @kirillfedorenko5325
    @kirillfedorenko5325 2 місяці тому

    im also improving my english watching your tutorials and not just scripting skills!

  • @noam190
    @noam190 4 роки тому +6

    to avoid it getting stuck you can just keep generation a waypoint and move to index 1 everytime

    • @squidiskool
      @squidiskool 3 роки тому

      What? I don't know what you are saying?

    • @bigamingplayer2409
      @bigamingplayer2409 2 роки тому

      You should just make it generate a waypoint only every time it gets stuck because if you keep generating waypoints constantly, it will take up server ram and cause lag which isn't good for optimization, Great Idea though!

  • @Nathanator
    @Nathanator 4 роки тому +55

    Thanks for the amazing tutorial! I’m using it for a game similar to Work at a Pizza Place. I needed pathfinding so I could spawn NPCs at random locations. They needed to walk to the cashier to take their orders lol.

    • @TheDevKing
      @TheDevKing  4 роки тому +17

      nice :D

    • @Nathanator
      @Nathanator 4 роки тому +5

      Thanks :D

    • @YorktownClass
      @YorktownClass 2 роки тому +3

      @@Nathanator how's the game going?

    • @Nathanator
      @Nathanator 2 роки тому +5

      @@YorktownClass I ended up quitting Roblox development due to being busy with school and other things, I'm working on becoming an app developer instead now.

    • @YorktownClass
      @YorktownClass 2 роки тому +2

      @@NathanatorWell i wish u good luck on achieving that! but can you tell me what's the *real* reason you stopped? (i'm making a game and if you can give me a headsup can really do me favor) btw i bet you forgot about this comment looll

  • @JimmyButBetter
    @JimmyButBetter 2 роки тому

    Just spending a few hours on roblox devhub repeating the basic coding lessons and then coming here its easier to understand what a part of code does and not directly copy paste something someone made not knowing what it does.

  • @cookiedev8527
    @cookiedev8527 3 роки тому

    Now I know how to make AI's for my enemies in my games u are a legend

  • @thetrickyitch7179
    @thetrickyitch7179 4 роки тому +4

    So with this method, which matches what's on the wiki for pathfinding, the pathing NPC will start to momentarily pause at each point along the path. You can see this start at 19:22. Any idea how to correct this?

    • @somedude0001
      @somedude0001 2 роки тому

      Basically in the script at the first put: script.Parent:SetNetworkOwner(nil)

  • @top-nerdygamer5921
    @top-nerdygamer5921 4 роки тому +31

    I just turned my local stop sign into a humanoid and its chasing me, help me

  • @RowStudio
    @RowStudio 4 роки тому

    this is extremely helpfull

  • @ster_joke2880
    @ster_joke2880 3 роки тому

    SOOO SWAGGG

  • @orange6230
    @orange6230 2 роки тому +93

    Hello, everyone! if you are too lazy to type the script, here is the fully written sc:
    local PathFindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    local path = PathFindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.EndingPart.Position)
    local Waypoints = path:GetWaypoints()
    path.Blocked:Connect(function()

    end)
    for i, Waypoint in pairs(Waypoints) do
    local part = Instance.new("Part",workspace)
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = Waypoint.Position + Vector3.new(0, 2, 0)
    part.Anchored = true
    part.CanCollide = false

    if Waypoint.Action == Enum.PathWaypointAction.Jump then
    human.Jump = true
    end
    human:MoveTo(Waypoint.Position)

    human.MoveToFinished:Wait()
    end
    human:MoveTo(game.Workspace.EndingPart.Position)

    • @superbtw.
      @superbtw. 2 роки тому

      I used this and it just created neon ball parts. not moving the character or anything
      Edit: It was a different character type. now its fixed

    • @CinnappleWasTaken
      @CinnappleWasTaken 2 роки тому

      YOU ARE A LIFE SAVER

    • @CinnappleWasTaken
      @CinnappleWasTaken 2 роки тому

      YOU DESERVE A LIKE

    • @orangeshorts8487
      @orangeshorts8487 Рік тому

      i just saved myself later on wow

    • @G3k0gtag
      @G3k0gtag Рік тому

      im lazy, thanks

  • @maxbuilder6801
    @maxbuilder6801 4 роки тому +23

    You know, this would make a great game idea, you have to get the bot or AI to the finish line, and you have to help it get there.

    • @soronorjspro3516
      @soronorjspro3516 4 роки тому

      This concept has been used, it is really cool. Good thinking.

    • @migriv4603
      @migriv4603 4 роки тому

      Make it!

    • @CTahmid
      @CTahmid 4 роки тому

      soronorjspro show us

    • @maxbuilder6801
      @maxbuilder6801 3 роки тому +2

      @@migriv4603 Perhaps I will make it... perhaps.

    • @pavlova3310
      @pavlova3310 2 роки тому

      @@maxbuilder6801 yes make it best idea ever! I'm gonna make it but not publish

  • @superduperman8287
    @superduperman8287 Рік тому +1

    I took a break for a long time from this series and after this ill be going to new territory! "I was just reviewing to refine my skills"

  • @MJV1958
    @MJV1958 Рік тому

    Bro thank youuuuuu😁😁😁

  • @barkmemes
    @barkmemes Рік тому +4

    do not go to 20:29 and turn on subtitles!! worst mistake of my life 😭

  • @calebaraujo8187
    @calebaraujo8187 4 роки тому +8

    Can you make a tutorial on a autopilot car where you can select the location where it’s gonna go and turn it of if you want?

    • @okidokie8
      @okidokie8 4 роки тому +7

      Isnt this video showing how?

  • @K4E1234
    @K4E1234 2 роки тому

    i made it, made a cool path and for some reason it flies over the parts, lol. i know this is still kinda like an "alpha" pathfinding service but ye, nice vid

  • @bowling3414
    @bowling3414 14 днів тому +1

    If you use R15, this won't work exactly the same, use an R6 model because it has "Torso" and not "Upper" or "Lower Torso." I haven't gotten the r15 to work but I assume you can target both upper and lower torso at the same time to be able to move it. Or perhaps it's humanoidrootpart, but I haven't figured it out.

  • @LukeGabriel
    @LukeGabriel 4 роки тому +9

    Messaging Service noww hehe, trying to make a global matchmaking system hehe so would definitely appreciate a helpful video 😀

    • @TheDevKing
      @TheDevKing  4 роки тому

      Coming soon :)

    • @LukeGabriel
      @LukeGabriel 4 роки тому

      @@TheDevKing 🙏🙏🙏

    • @LArk25
      @LArk25 4 роки тому +1

      alvinblox made a video on messaging service - ua-cam.com/video/uI6MIZ3Y7ZY/v-deo.html
      alvinblox is also a good roblox scripting youtuber

    • @DanielP533Scripts
      @DanielP533Scripts 4 роки тому +1

      @@LArk25 for beginners. this is the advanced series

    • @ultra3806
      @ultra3806 3 роки тому

      @@DanielP533Scripts that tutorial is still helpful...

  • @justarandom1947
    @justarandom1947 3 роки тому +11

    20:00 instant karma XD

  • @DWilliams
    @DWilliams 3 роки тому

    I remember watching your videos.

  • @NotResponding404
    @NotResponding404 3 роки тому

    I’m gonna make it go after the player thanks!

  • @XeviousGG
    @XeviousGG 4 роки тому +5

    what about when it plots a course through a small gap that it cant fit through? i suppose that falls under the blocked category?

  • @simplerpianisto6699
    @simplerpianisto6699 3 роки тому +3

    Hey man, i checked this tutorial out just to learn pathfinding and its super helpfull. I already made my own pathfinding function through a whole map and everything but when i move around the mob it sometimes just gets confused and stops moving. Is there maybe a solution for this?

    • @alive4269
      @alive4269 2 роки тому

      send a code, we'll help you troubleshoot

    • @dopxy9219
      @dopxy9219 2 роки тому

      @@alive4269 a year late

    • @Luke_alaxander
      @Luke_alaxander 7 місяців тому

      what@@dopxy9219

    • @Luke_alaxander
      @Luke_alaxander 7 місяців тому

      do you still need help

  • @Mcnikkins75
    @Mcnikkins75 3 роки тому

    The most important thing I learnt is NEVER EVER CHALLENGE AIs OR AI BOTS.
    PS most funniest video by mat--no the devking

  • @umbbrll
    @umbbrll Рік тому

    im gonna use this in my albion online ripoff lol thanks!

  • @nicksloan9323
    @nicksloan9323 3 роки тому +41

    script for lazy people like me:
    local PathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    local path = PathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.endingpart.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoint in pairs (waypoints) do
    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end

    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
    end
    Your welcome

    • @gavpa6331
      @gavpa6331 3 роки тому +1

      thanks

    • @nicksloan9323
      @nicksloan9323 3 роки тому

      @betagam4523p any way to make it control a car to go to a location then? ive been trying to find how to do it without neural networks, but ive had no luck. i kinda need help with this, thanks. What im trying to do is to make an ai police car basically, like in need for speed rivals, that are suprisingly blood thirsty to destroy your car

    • @ikeahedgehog
      @ikeahedgehog 3 роки тому

      Thanks a lot, i was very lazy to do this thing.

    • @menofscoobistherepublic7660
      @menofscoobistherepublic7660 3 роки тому

      thanks bro

    • @realization3020
      @realization3020 3 роки тому

      @betagam4523p I'm working on a taxi whit the script. Thank you so much!

  • @NecronyxRB
    @NecronyxRB 4 роки тому +3

    Hey DevKing do you think we could teach the AI to climb and swim?
    Edit: oh wait nvm you can!
    Edit 2: ok so the AI can’t actually calculate them being able to climb so it disables there ability to jump, maybe we could fix thris

  • @muffins9917
    @muffins9917 4 роки тому

    THE ULTIMATE SPEED RUNNER

  • @mna.author
    @mna.author Рік тому +2

    For me, the script worked and everything was fine, but when I put a more complicated one with more jumping, it doesn't work. What could cause such an issue?
    Update: It is not reading the for loop. Does anyone know why?

  • @mickeypoophead4566
    @mickeypoophead4566 2 роки тому +5

    What if I want to have two checkpoints and I want the NPC to walk in a loop without stopping?

    • @WaW_Real
      @WaW_Real Рік тому

      yeah thats a problem XD

    • @vibemusic6478
      @vibemusic6478 Рік тому

      @@WaW_Real no its not its really easy :/

  • @dawsify6393
    @dawsify6393 4 роки тому +4

    could you make a tutorial about making learning ai from hello neighbor the stealth horror game. so that the bot learns and sets up traps and blocks doors the more times you go into a certain area

    • @MrCreepyPeach
      @MrCreepyPeach 3 роки тому +1

      that sounds way too advanced to be explained in one video

    • @crystalscreens9057
      @crystalscreens9057 3 роки тому +1

      Bro, even piggy doesn't have that.

    • @doggosaurs3489
      @doggosaurs3489 3 роки тому +2

      Roblox pathfinding is not that advanced

    • @aawnwjua
      @aawnwjua 2 роки тому

      2030 have that

    • @rc8s
      @rc8s 2 роки тому +1

      idk why everyone is acting like it's making the ai become sentient, you can just check if the player went in a certain area and then make the ai set up more traps. Hello neighbor AI isnt that good

  • @gingerbloxplays
    @gingerbloxplays Рік тому

    thanks!!

  • @alplayzmc3034
    @alplayzmc3034 4 роки тому +2

    Great video but at 13:39 why didn't you just type humanoid.Jump = true. Instead of all that other stuff? Also, you didn't get rid of the strait moveto

    • @clov3r527
      @clov3r527 4 роки тому

      Does it work the same I have never tried it but I will try it if it works.

  • @vplayz2101
    @vplayz2101 11 місяців тому +5

    Roblox did some updates, and I fixed the script, because in the new version the AI will infinitely double-jump. (This is for R15)
    local pathfinding = game:GetService("PathfindingService")
    local hum=script.Parent:WaitForChild("Humanoid")
    local rootPart=script.Parent.HumanoidRootPart
    local path=pathfinding:CreatePath()
    path:ComputeAsync(rootPart.Position,game.Workspace.Target.Position)
    local waypoints=path:GetWaypoints()
    for i, waypoint in pairs(waypoints) do
    if waypoint.Action==Enum.PathWaypointAction.Jump then
    if not(hum:GetState()==Enum.HumanoidStateType.Freefall) then
    hum:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    end
    hum:MoveTo(waypoint.Position)
    hum.MoveToFinished:Wait()
    end

    • @chezzodev
      @chezzodev 5 місяців тому +1

      Thank you, been trying to figure out what was wrong with my code ♡☆

  • @jaspersakk2387
    @jaspersakk2387 2 роки тому +4

    It looks a lot more complicated with dark mode on

  • @fusionburstofficial
    @fusionburstofficial 3 роки тому

    how do you make the npc follow a specific guy. Like think I have a player with a value called "Notplayer" inside of the player. And there is a player who does not have the value. And I want it so that I want the guy with the value be followed by the npc. How do you do that?Can you make a separate video of that pls pls?

  • @raymint6118
    @raymint6118 4 роки тому

    I need some help like when I put the script It doesn't move altho I removed the wander bc It always wander away from the path Is there anything Im doing wrong?

  • @gdev6632
    @gdev6632 2 роки тому +7

    If you want to you can add more parts to make like a smooth line like this:
    local PathFindingService = game:GetService("PathfindingService")
    local Human = script.Parent:WaitForChild("Humanoid")
    local Torso = script.Parent:WaitForChild("Torso")
    local path = PathFindingService:CreatePath()
    path:ComputeAsync(Torso.Position, workspace.endingPart1.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoints in pairs(waypoints) do
    Human:MoveTo(waypoints.Position)
    Human.MoveToFinished:Wait(2)
    end
    local path = PathFindingService:CreatePath()
    path:ComputeAsync(Torso.Position, workspace.endingPart2.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoints in pairs(waypoints) do
    Human:MoveTo(waypoints.Position)
    Human.MoveToFinished:Wait(2)
    end

    • @KyleBunnyBunsYTube
      @KyleBunnyBunsYTube 2 роки тому +1

      how do i make it so that the NPCs don't walk into the walls while trying to get to waypoints

    • @Jonskipvp
      @Jonskipvp 2 роки тому +2

      @@KyleBunnyBunsYTube Keyboard

  • @spongous4826
    @spongous4826 4 роки тому +3

    is it possible for the NPC to pathfind a player instead of a brick?

    • @Iron88321
      @Iron88321 2 місяці тому

      You could add a simple player finder as well, so have it say patrol with the brick system then it will break off when it sees a player and then it would go back to patrolling when player is dealt with or far away

  • @HistoricalFanatics
    @HistoricalFanatics Рік тому

    im using this for Movement in my FNAF styled game Thank you

  • @jan251025
    @jan251025 Рік тому

    you can turn on nav mesh to see where he can stand on and where not

  • @pukmint
    @pukmint Рік тому +3

    How do you make a new path if the old one gets blocked?

    • @afterpartyslays
      @afterpartyslays 2 місяці тому

      you probably do path:ComputeAsync() again (but i havent tried it)

  • @tuffer.
    @tuffer. Рік тому +6

    If anyone want's to make it so that it creates a new waypoint to follow when you move the end part then copy this script:
    local PathFindingService = game:GetService("PathfindingService")
    local hum = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    -- A little feature that I added to put the spheres inside a folder to make it less messy in the workspace
    local PathSpheres = Instance.new("Folder")
    PathSpheres.Name = ("Paths")
    PathSpheres.Parent = game.Workspace
    local path = PathFindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.EndingPart.Position)
    local Waypoints = path:GetWaypoints()
    path.Blocked:Connect(function()
    end)
    for i, Waypoint in pairs(Waypoints) do
    local part = Instance.new("Part",game.Workspace.Paths)
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = Waypoint.Position + Vector3.new(0, 2, 0)
    part.Anchored = true
    part.CanCollide = false
    if Waypoint.Action == Enum.PathWaypointAction.Jump then
    hum:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    hum:MoveTo(Waypoint.Position)
    hum.MoveToFinished:Wait()
    end
    while wait(0.15) do
    local part = Instance.new("Part",game.Workspace.Paths)
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = torso.Position - Vector3.new(0, 1, 0)
    part.Anchored = true
    part.CanCollide = false
    hum:MoveTo(game.Workspace.EndingPart.Position)
    end

  • @VerekEdits
    @VerekEdits Місяць тому

    Remember to set the ending position block to be no collide! Solved it for me

  • @Gryfn_
    @Gryfn_ 2 роки тому

    Would a pathfinding script work on something like a grenade? For example could I script the grenade to track down other players?

  • @felixiplang
    @felixiplang 3 роки тому +4

    What about making a part go to another part using pathfinding?

    • @ausbossmoved
      @ausbossmoved 2 роки тому

      make the npc invisible and attach your part to it

    • @aunber
      @aunber 2 роки тому +1

      @@ausbossmoved or just tween along the waypoints like you'd normally do

  • @rainerruseigen8351
    @rainerruseigen8351 3 роки тому

    if your npc is not working
    try to delete a humanoid in the workspace, that fixed it for me

  • @dumy9809
    @dumy9809 4 роки тому

    How did you select the rams like that without morning your cursor to explorer??

  • @isaiahbenjamins8818
    @isaiahbenjamins8818 3 роки тому +3

    Im a little late to the party but how would i make the npc move towards a player?

  • @fred_uh
    @fred_uh Рік тому +75

    POV: ur watching this in 2022 cuz you don’t know how to code yet

    • @floof6896
      @floof6896 Рік тому +21

      pov: you know how to code and know all the basics and most advanced things but you just need to know how to code an ai

    • @phoenixfire4393
      @phoenixfire4393 Рік тому

      Lol

    • @phoenixfire4393
      @phoenixfire4393 Рік тому +2

      I'm in 2022 cuz I'm learning how to code

    • @BRY0402
      @BRY0402 Рік тому +1

      @@floof6896 tru

    • @XYWZExtreme
      @XYWZExtreme Рік тому +1

      The Jokes on You,I forgot everything aside from the very basics of the syntax and redoing the advanced series again

  • @totalyold8103
    @totalyold8103 4 роки тому +2

    Hey!
    Would it be possible to weld the end part to a startercharacter and have it follow you forever?

    • @per_cept
      @per_cept 4 роки тому +1

      or make it detect a player in the area and follow the root part of the player

    • @walterclements3957
      @walterclements3957 4 роки тому

      @@per_cept yes you would use magnitude

    • @penggrin
      @penggrin 2 роки тому

      "weld" would work just bad, use "weld constraint"

  • @xOmqduperJJ
    @xOmqduperJJ 5 днів тому

    Update: you no longer need a plugin to insert your own avatar, I know this video wasn't young enough to notice but you now can use the built-in "Rig Inserter" to insert your own avatar, How? Besides Block, Mesh, Slender, and RThro there is a "Your avatar button".

  • @CloverKismet
    @CloverKismet 2 роки тому +3

    Apply Auto-Subtitles here (20:24). What a slip up, DevKing; RIP my innocent brain.

  • @CorruptedDioSan
    @CorruptedDioSan Рік тому +10

    If any of you want the NPC to go to the object that moved WITHOUT slowdowns then I was able to make a script below:
    ~~~
    local pathfindingService = game:GetService("PathfindingService")
    local target = game.Workspace.Finish
    local targetPosition = game.Workspace.Finish.Position
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    while true do
    wait()
    local path = pathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.Finish.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoint in pairs(waypoints) do
    if target.Position == targetPosition then
    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:wait()
    else
    targetPosition = target.Position
    break
    end
    end
    end
    ~~~
    *The script above is RIG 3rd script, the stuff below will tell you about the other Rigs*
    I made a script which moved the object every 5-10 seconds and after moving the RIG3 ( I had 3 different rigs) moved to the object immediately
    Rig 1 was the one The Dev King did but with the while true loop, but the problem is that he was going to the position if after the object was moved so only after he reached position he would go to a new one:
    ~~~
    local pathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    while true do
    wait()
    local path = pathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.Finish.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoint in pairs(waypoints) do
    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait()
    end
    end
    ~~~
    Rig2 on the other hand moved immediately after the object moved but the problem is that he was stuttering every step he took, meaning he would take a step and freeze for a sec, and the other problem is that he couldn't jump at all:
    ~~~
    local pathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    while true do
    local path = pathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, game.Workspace.Finish.Position)
    local waypoints = path:GetWaypoints()
    local waypoint = waypoints[2]
    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:wait()
    end
    ~~~
    And after using the mistakes from 2 rigs I was able to improve my pathfinding

  • @_rezalet_kanal_
    @_rezalet_kanal_ 9 місяців тому

    W tutorial

  • @pavlova3310
    @pavlova3310 2 роки тому +1

    Best tutorial ever! But the NPC can double jump, even while falling, does anyone know why?

  • @harveyflaxcaster8257
    @harveyflaxcaster8257 4 роки тому +4

    Every tutorial I watch nothing works and I'm getting sick of it. I've already smashed two keys in because of it

    • @robingibson5445
      @robingibson5445 4 роки тому

      On line 11 , the word waypoint , on my computer it says it's errored . So I tried putting a s at the end of it like the blue thing that pops up suggested . Neither worked . Am I missing something ? I double checked also

    • @harveyflaxcaster8257
      @harveyflaxcaster8257 4 роки тому

      @@robingibson5445 if your bullet is not firing make sure it is not on the ground

  • @JohnnyLiberal69
    @JohnnyLiberal69 4 роки тому +3

    I kinda wish I had waited for this video...

    • @TheDevKing
      @TheDevKing  4 роки тому

      lol uhh well now its here! :)

  • @ydmj-on-discord
    @ydmj-on-discord 9 місяців тому

    WORKS!!!

  • @kitkatcitcat5761
    @kitkatcitcat5761 3 роки тому +1

    i put a part
    be proud of me

  • @sour-1301
    @sour-1301 7 місяців тому +3

    POV: ur watching this in 2023 because u don't know how to code yet

  • @BertusTheGreat1
    @BertusTheGreat1 4 роки тому +3

    tap water

  • @bobrillaYT
    @bobrillaYT 3 роки тому +2

    12:00 marking my spot for now

  • @mdes0819
    @mdes0819 Рік тому

    For r15 there is no torso there is upper torso or lower torso because of that I use the HumanoidRootPart witch every character has

  • @itskindasimple4523
    @itskindasimple4523 4 роки тому +8

    You are welcome.
    local PathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    local path = PFS:CreatePath()
    p:ComputeAsync(t.Position, game.Workspace.endingPart.Position)
    local waypoints = p:GetWaypoints()
    for i, waypoint in pairs(waypoints) do
    local ball = Instance.new("Part")
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = waypoint.Position + Vector3.new(0,2,0)
    part.Anchored = true
    part.CanCollide = false
    part.Parent = game.Workspace

    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
    end
    human:MoveTo(game.Workspace.endingPart.Position)

  • @NotReallyNeon
    @NotReallyNeon Рік тому +7

    Here's the code if anyone wants all the waypoints to show before he starts moving, with colour changing waypoints when he gets to that waypoint:
    local Pathfind = game:GetService("PathfindingService")
    local Humanoid = script.Parent:WaitForChild("Humanoid")
    local Torso = script.Parent:WaitForChild("Torso")
    local Path = Pathfind:CreatePath()
    local Target = workspace.Target
    local GenPoint = nil
    local PointArray = {}
    local Folder = Instance.new("Folder")
    Folder.Name = "Waypoints"
    Folder.Parent = workspace
    Path:ComputeAsync(Torso.Position, Target.Position)
    local Waypoints = Path:GetWaypoints()
    for i, v in ipairs(Waypoints) do
    GenPoint = v
    print(GenPoint)
    table.insert(PointArray, GenPoint)
    local Point = Instance.new("Part")
    Point.Anchored = true
    Point.Shape = "Ball"
    Point.Size = Vector3.one*0.5
    Point.Position = v.Position + Vector3.new(0,2,0)
    Point.CanCollide = false
    Point.Parent = workspace.Waypoints
    Point.Name = "Point"..tostring(i)
    end
    for i2, v2 in ipairs(PointArray) do
    if v2.Action == Enum.PathWaypointAction.Jump then
    Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    Humanoid:MoveTo(v2.Position)
    Humanoid.MoveToFinished:Wait()
    workspace.Waypoints["Point"..tostring(i2)].BrickColor = BrickColor.new("Camo")
    workspace.Waypoints["Point"..tostring(i2)].Material = "Neon"
    end

  • @wuyaya7849
    @wuyaya7849 3 роки тому +1

    the "smart" zombie does not go all the way round. The goes around the first wall then decides that he can't be bothered to walk around the second wall. He walkeds into it and stops.

    • @KyleBunnyBunsYTube
      @KyleBunnyBunsYTube 2 роки тому

      literally every single tutorial i watched doesn't even do anythng to make it so that the NPC doesn't walk straight into walls.

    • @specsamhain_909
      @specsamhain_909 Рік тому

      i'm having the same issues too..!

  • @specsamhain_909
    @specsamhain_909 Рік тому +1

    i tried this, but something unusual happened, they seemed to be hellbent on bunching up at a certain point on the map that was odd, before moving on to the goal... i don't know how to fix this...

  • @JoshuaDZ
    @JoshuaDZ 4 роки тому +7

    Here is the script for you all to copy and paste :D
    endingPart = game.Workspace.endingPart --change this to where it is in the workspace
    while true do
    local PathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    local path = PathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, endingPart.Position)
    local waypoints = path:GetWaypoints()
    for i, waypoint in pairs (waypoints) do


    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
    end
    human:MoveTo(endingPart.Position)--change here
    end
    while true do
    local PathfindingService = game:GetService("PathfindingService")
    local human = script.Parent:WaitForChild("Humanoid")
    local torso = script.Parent:WaitForChild("Torso")
    local path = PathfindingService:CreatePath()
    path:ComputeAsync(torso.Position, endingPart.Position) --change the endingPart to the part you want it to walk to
    local waypoints = path:GetWaypoints()
    for i, waypoint in pairs (waypoints) do


    if waypoint.Action == Enum.PathWaypointAction.Jump then
    human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
    end
    human:MoveTo(endingPart.Position)--change here
    end

    • @teamcatyt4503
      @teamcatyt4503 4 роки тому +1

      what do u mean by --change this to where it is in the workspace

    • @JoshuaDZ
      @JoshuaDZ 4 роки тому

      @@teamcatyt4503 change it to the name of the part

    • @teamcatyt4503
      @teamcatyt4503 4 роки тому

      @@JoshuaDZ its a model. The script i am putting is in the npc. I insert the name of it and next the pos?

    • @DanielP533Scripts
      @DanielP533Scripts 4 роки тому +2

      @@teamcatyt4503 You should watch the beginner's series and work your way up. This script should be easy to comprehend.If you want the destination to be a model, then set the primary part of that model and set it there. This is why you watch the video to learn and not just copy/paste from description

    • @theyarecloseultra942
      @theyarecloseultra942 4 роки тому +2

      Stop making people lazy