Roblox Enemy NPC Tutorial - Part 1

Поделиться
HTML-код
  • Опубликовано: 17 янв 2025

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

  • @SlothOfTheSea
    @SlothOfTheSea 2 года назад +43

    I have spent many painstakingly long hours trying to learn Pathfinding and other things like this, but this was really easy to follow and somewhat easy to understand. Liked and subscribed!

  • @bonesReal
    @bonesReal 2 года назад +11

    A moment of silence for this man, he didn't have coffee this morning 😢
    btw awesome tutorial my man

  • @ayobros7788
    @ayobros7788 Год назад +3

    Great Tutorial! So clear and works great. Keep it up

  • @Charley1289
    @Charley1289 Год назад +2

    I thought it would not work, like some of the other tutorials I tried, but this guys a legend!!!

  • @BobSuper1
    @BobSuper1 Год назад +2

    Thank you so much! It took me forever to find a tutorial that i understand. You earned a like and a sub :)

  • @oldsci82
    @oldsci82 2 года назад +6

    Awesome video!! After searching multiple different videos yours was the one that explained it all and made it easy. I liked the speed of the video, the explanation of the lines of code, and the tenor of your audio (no screaming or crazyness). Great job! I really appreciate it!

  • @coolcosmic4351
    @coolcosmic4351 Год назад +2

    Thank you, I created a enemy in roblox studio back in 2016 I believe that I wanted to make for a game, but got discouraged when I couldn't figure out how to get it to chase players. Now you've given me a basic idea on what I need to do in order to create enemies for my games.👍

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

      Have u finished it yet ? what is ur user name

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

      @@Zero9xi No. Also thanks to my own situatiion I don't think I will be able to finish it for quite some time.

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

      @@coolcosmic4351 mk

  • @alexanderhsl
    @alexanderhsl 2 года назад +4

    Thank you SO SO much. I'm making a survival game and I've been searching for a great tutorial like this! Glad I found this.

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

    Sorry I am late, but this tutorial helped me a lot, but I didn't understand all of it, so I got the model that you put in, sorry. Great tutorial! Your voice was loud and clear, you said everything so understandable.

  • @rafaelbrustolin4687
    @rafaelbrustolin4687 Год назад +2

    Im just starting to script and your tutorial helped me more than I could ever imagine

  • @epsilon-dinosaur
    @epsilon-dinosaur Год назад +1

    Yoo thanks for the tutorial! it helped me a lot :D

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

    DUDE THANK YOU SO MUCH! I have been looking for hours for a script like this!

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

      @@URANUS113 Yes

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

    Thank you for this video, it helped out so much, and thanks for going slow with writing the code and explaining the important parts!

  • @skyflyser9463
    @skyflyser9463 Год назад +18

    MrModuleScript:"Now we have to deal with a nil value in our heartbeat" bro thats dark

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

    ty bro, me and my friend needed the best tutorial on this :)

  • @xb_desamaster8882
    @xb_desamaster8882 Год назад +3

    This video is 1 year old but yet it helped me out so much 🥰. 3 days of looking for the perfect video was worth it, you earned a like and subscription from me.

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

      can you text me the script it doesnt work for me

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

    thank u for ur helpful tutorial , u just saved me hours of learning

  • @spung0
    @spung0 2 года назад +1

    Yo, i can tell this man is gonna be pretty big soon. I mean content is pretty good and he's pretty master. I just have 1 tip to get bigger. Make more tutorials that people are most likely going to search for. Like this video is a pretty good one. Keep it up!

    • @ReallyPieThings
      @ReallyPieThings 2 года назад +1

      We just gotta hope he uploads more tutorials, the first 2 were helpful

  • @flamzy284
    @flamzy284 2 года назад +8

    If it isn't moving make sure the torso or humanoidrootpart is unanchored

  • @lilfajita
    @lilfajita 2 года назад +5

    Finally! I got it to work, I just had to un anchor the humanoid root part! Thanks so much for the great vid it helped me so much

  • @JohnnyBoi08
    @JohnnyBoi08 2 года назад

    incredibly useful tutorial, cant count the number of hours ive been trying to learn how to do this. Liekd and subscribed.

  • @fhnine2698
    @fhnine2698 2 года назад +1

    was desperated until I found my mistake is a syntax error in the script; now it works fine for me Thanks a lot, keep going

    • @MrModuleScript
      @MrModuleScript  2 года назад +1

      Glad you got it working! Part 3 is on its way!

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

    8:37 bro direction is an absolute UNIT
    hehehehehehehehehehehehehehehhehehehehehhehhhehhe E
    E
    e
    e


    .
    .
    spiderman
    on his way home

  • @Crippley
    @Crippley 2 года назад +4

    This is so cool and I had fun following along!! I still struggle to understand the "why" for a lot of things in script as a newbie, but I'm sure it'll make sense the more I learn. thank you for this video. :^D

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

    Epic video Didn't know a tutorial like this existed

  • @gointorealheaven-jj5od
    @gointorealheaven-jj5od Год назад

    Finally, a video that doesn't make me copy and paste the script

  • @dababy3303
    @dababy3303 2 года назад +2

    I guess I am just really dumb and did something wrong because I downloaded the script and it worked but mine did not lol. You have earned a sub man!

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

    yoo broo, really apprechiate that you made this vid, also do you know how i could make the dummy walk faster?

  • @tugjames4528
    @tugjames4528 2 года назад +1

    I'm so happy this works with r6 as well

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

    This will really help with my friends game! Thanks alot!

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

    You are a w man this will help me so much thank you🙂

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

    do i have to put it to nil or some other name?

  • @FireFuzzball673
    @FireFuzzball673 2 года назад +1

    thank you are the only one that i found that does not do copy and paste

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

    thanks i watched this for a game with my friends :)

  • @tikel5563
    @tikel5563 2 года назад

    Thank you so much for a legit script that works very nicely!

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

    this helped me out so much

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

      HOW IS THIS 2 WEEKS AGO?!
      it did'nt work for me :( can you tell me what i mabye did wrong?

  • @blinggaming7707
    @blinggaming7707 Год назад +3

    Does anyone know how to fix the error where it says that move is not a valid member of part?

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

      Move should be only used on the humanoid, which I set as a variable. If the error says "not a valid member of part", then either the humanoid variable must be incorrectly set to a part (such as the humanoid root) rather than the humanoid, or you are trying use :move() on the wrong variable. Hope this helps!

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

      @@MrModuleScript ok thanks I’ll try it.

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

      @@MrModuleScript OMG IT WORKED BRO TYSM!

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

      @@MrModuleScript IM MAKING A HORROR GAME SO THIS WILL HELP A LOT

  • @beanman2030
    @beanman2030 Год назад +2

    Workspace.Model.Humanoid.EnemyController:20: attempt to index nil with 'Position' So I created my own model and rigged it my self and tried to implement the code on it but it just pops up as Workspace.Model.Humanoid.EnemyController:20: attempt to index nil with 'Position'
    idk if its because its a four legged model instead of a r15 or r6 model but it still has the humanoid in it. I could really appreciate the help.

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

      I'm having the same issue,
      Workspace.Model.Humanoid.Script:24: attempt to index nil with 'Position'

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

      just set the primary part of your model (usually HumanoidRootPart).

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

      @@Spearit_S Yep that was the problem, thank you.

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

    very epic and cool

  • @tobiasleijdesdorff9960
    @tobiasleijdesdorff9960 2 года назад +1

    Thanks For The Video!

  • @angelquefirestar
    @angelquefirestar 2 года назад +1

    This is really helpful for making a Partygoer in my Backrooms game!

  • @MrModuleScript
    @MrModuleScript  2 года назад +3

    Looks like the video was recorded in 720p... I'm so sorry. Woops! The next videos will be back to 1080p. Sorry if the video looks a little blurry!

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

    bro earned a sub faster than me looking for my dad

  • @calebetheredge9307
    @calebetheredge9307 2 года назад +1

    can you make a tutorial so that we can make a mesh with a humanoid in it attack you instead of a dummy

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

    I can't figure out why my custom rig isn't working with the Script

  • @mykidneyhurts1372
    @mykidneyhurts1372 2 года назад +2

    Btw can you paste script here im having hard time making a game so putting the script in the comments will really help me.
    Even if you dont thx for tutorial

  • @B_duzzle
    @B_duzzle 2 года назад +2

    can I use r6 dummy?

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

    there a way to make it only target you when you're on a certain team?

  • @PolyVein
    @PolyVein 2 года назад +1

    How would i add animations to this?

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

    If I could subscribe twice, I would. No thumbs up, all my fingers up! (Which doesnt make sense but still...) I'm oof to part 2!!

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

    sat here for 20 minutes (real) looking through the script for why it wouldnt work whatsoever, and i finally realized i forgot an end at line 31. coding is so fun i want to do it everyday

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

      use script analysis and output

  • @Iceless_0
    @Iceless_0 2 года назад

    Will there be a second part?
    subbed btw

    • @MrModuleScript
      @MrModuleScript  2 года назад +1

      In the process of finishing it! Just have to finish the last parts of editing the video. Thanks!

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

    thank you! :D

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

    Could you also make dummy that helps you in a battle

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

    I Subscribed!

  • @24Chico
    @24Chico Год назад

    Hey, I have a Question can you make the dummy slower somehow?

  • @pistolgames232
    @pistolgames232 2 года назад +4

    Thank you, this video was very helpful for me, but i'm curious about how can i make npcs go back to their spawn or other places after they stopped chasing player?

    • @TheSparkySpitz
      @TheSparkySpitz 2 года назад +1

      just set their root CFrame to the span location CFrame after the player is outside the distance.

    • @BushWithAGun
      @BushWithAGun 2 года назад +1

      idk how to do that tho

  • @какменязовут-ж7х
    @какменязовут-ж7х 2 года назад +1

    i have one question, how i change the speed of the model, i want to make a faster chaser

    • @thedumbguy0w033
      @thedumbguy0w033 2 года назад

      Go to the humanoid of the npc and then change its walkspeed

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

    am i able to put the finished model in my game (the one in the description) I am going to edit the character

  • @arnabdutta1984
    @arnabdutta1984 2 года назад +4

    Just add the following line if r15 does not move
    root.Anchored = false

    • @jackforest8084
      @jackforest8084 2 года назад

      Thank you so much! I knew i had an anchoring issue, i just did not know how to fix it.

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

    quick question, when it doesnt see you can it just walk in any direction?

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

    this is the birth of the student enemy for me

  • @alex342gwsturk8
    @alex342gwsturk8 2 года назад

    thanks so much but does it work with r6? i havent tried it yet

    • @hunnydrawz8569
      @hunnydrawz8569 2 года назад

      creator said it should, and in all reasons it should, but you should def try it

    • @alex342gwsturk8
      @alex342gwsturk8 2 года назад

      @@hunnydrawz8569ok

  • @MikaChristensen-j2e
    @MikaChristensen-j2e 6 месяцев назад +1

    i cant do it its to hard for me :(

  • @energyslayr1723
    @energyslayr1723 2 года назад +1

    Help me the
    Runservice.Heartbeat does not work

  • @wethebest-obamiumcore1457
    @wethebest-obamiumcore1457 2 года назад +1

    thanks man it works, but do you have any way to make it that it avoids walls? it will chase me but it gets stuck in walls and other obstacles

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

    can you make it stop after being to far away like the chasing is a range?

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

    You deserve more subs

  • @lordkoreth3656
    @lordkoreth3656 2 года назад +2

    what happened to the part 2?

    • @hunnydrawz8569
      @hunnydrawz8569 2 года назад

      roblox enemy NPC tutorial part 2. on his channel

    • @lordkoreth3656
      @lordkoreth3656 2 года назад

      @@hunnydrawz8569 yes, i know, but my question was 3 months ago.

  • @byuulahn9331
    @byuulahn9331 2 года назад +1

    after I downloaded the dummy it kept spawning in every of my baseplates. How can you make it stop?

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

    ty hehe

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

    thank you

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

    It doesn't work for me. I've tried lots of NPC tutorials, but nothing has happened. My dummy doesn't move a stud. Is my studio bugged??

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

      Make sure it isn't anchored. That seems to be the most common cause of this problem.

  • @Gameking1326_YT
    @Gameking1326_YT 9 месяцев назад +1

    I have an error saying "Unable to cast double to Vector3". My script is :
    local RunService = game:GetService("RunService")
    local Players = game:GetService("Players")
    local Humanoid = script.Parent
    local root = Humanoid.Parent.PrimaryPart
    local targetDistance = 20
    local stopDistance = 5
    function FindNearestPlayer()
    local playerList = Players:GetPlayers()
    local nearestPlayer = nil
    local distance = nil
    local direction = nil
    for _, player in pairs(playerList) do
    local character = player.Character
    if character then
    local distanceVector = (player.Character.HumanoidRootPart.Position - root.Position)
    if not nearestPlayer then
    nearestPlayer = player
    distance = distanceVector.Magnitude
    direction = distanceVector.Unit
    elseif distanceVector.Magnitude < distance then
    nearestPlayer = player
    distance = distanceVector.Magnitude
    direction = distanceVector.Unit
    end
    end
    end
    return nearestPlayer, distance, direction
    end
    RunService.Heartbeat:Connect(function()
    local nearestPlayer, distance, direction = FindNearestPlayer()
    if nearestPlayer then
    if distance = stopDistance then
    Humanoid:Move(distance)
    else
    Humanoid:Move(Vector3.new())
    end
    end
    end)
    Please someone help.

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

    is he able to like know that theres an object infront of him can go past stuff or just get stuck?

  • @ablaabl8315
    @ablaabl8315 2 года назад

    (pls reply)
    (in the script) when pressing enter there are a couple of spaces and the text appears more to the right, right. Does it mater if the space is there? (same thing about the "end" does it mater if it is there?

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

    I wanna make an npc like this that is friendly if you have a specific item or a specific team

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

    Make sure to use character.HumanoidRootPart.CFrame.Position instead of character.HumanoidRootPart.Position to calculate the distanceVector if you're getting errors about that

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

    can somebody explain me please,why it changes player at 9:57 line 20 after elseif i just can't understand why? (Sry for bad English)

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

      The if statement begins with: If there is NOT a nearest player, then the nearest player needs to be set to the nearest player (If you get what I mean). But if it IS, if there is another player that gets closer than the current set nearest player, then that player needs to be set as the nearest player instead

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

    is there a way to make it so that the enemy not follow the player but instead a different part, I'm trying to do the basse thing from tbb

  • @Freddie_Office
    @Freddie_Office 2 года назад +1

    how can I make a script that prints something in the console when you get a badge

    • @beelz1042
      @beelz1042 2 года назад

      local badgeService = game:GetService("BadgeService")
      local badgeId = (the badge id)
      If badgeServive:UserHasBadge(player.UserId, badgeId) then
      print("the player has this badge")
      else
      print("the player doesn't have this badge")
      end

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

    How do u make the NPC Track you down trough obstacles

  • @NoAdded
    @NoAdded 2 года назад

    Thanks!

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

    nice work i love it but its easyer if we could copy and past

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

    everytime i try the npc in studio and click play, there are hundreds of dummys on top of me, please help!

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

    thanks you but some times I have problems with anchoring my character. when I do, the character does not move. I usually use 3d models too.

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

      when you anchor the character, the character can't move because of that, you need to anchor it for make it move

  • @SNIPA007v2
    @SNIPA007v2 2 года назад

    i was losing my mind comparing mine and your code trying to figure out out a problem before i grabbed your model to compare the scripts, they looked the same and your dummy was giving chase so i tried to put your script in my dummy to see if it would run then and as it turns out this whole time the problem was coming from the model

  • @thechannel7988
    @thechannel7988 2 года назад

    can you create a monster that randomly attacks the player like Charles from "Choo Choo Charles" I understand that this game was made on a different game creation engine, but if possible, please do a tutorial on this

  • @mr.nixan3017
    @mr.nixan3017 2 года назад

    Is it a problem if my root part is the head? As im working with r6 as its easyer for animations.

  • @900GHXST
    @900GHXST 10 месяцев назад

    when i use a kickback move it completely flys away

  • @slxv7135
    @slxv7135 2 года назад +1

    Hey, it is not still working for me, and I can't really see the script bc it's really blurry so can you put the script in the description?

    • @MrModuleScript
      @MrModuleScript  2 года назад

      Sorry to hear that! In the description I have a link to the finished model for this part that includes the script within it. I'll leave it here as well: www.roblox.com/library/8898668736/Enemy-NPC-Part-1-Model?nl=true

  • @th3tnt1
    @th3tnt1 2 года назад

    Hey how to type the "is less than" thing on keyboard? Idk how

  • @macstorm2234
    @macstorm2234 2 года назад +20

    Part 1 results : How to make a "peacefull" enemy npc

    • @L4ng3l
      @L4ng3l 2 года назад

      Well you add a kill script, modify the damage and done
      That what I did with a npc

    • @macstorm2234
      @macstorm2234 2 года назад

      @@L4ng3lThats the part 2

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

    When testing with multiple players the script seems confused about which player/where to target. It seems to be trying to target both players at the same time instead of focusing on the single closest player

  • @RobloxSwordBattleofficialYouTu

    If you attack a specific part or player by pressing the roblox studio q and attacking it, the level Gui goes up and the level goes up, the physical strength and attack power go up pls

  • @WildPickle
    @WildPickle 2 года назад

    this is useful but could you at some point make one for models, not the normal dummy.

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

    how do you give the npc health i watched all parts but like no hp!!!!

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

    Trying to follow this using an enemy model I brought in from Blender. I got it to work for the R15 model but when I try and change the wording based on the model I am using I am getting a ton of errors so thinking I'm changing it wrong. Any tips on doing this for an injected model? This is the current error I am getting and it seems to not like Vector3.new: Move is not a valid member of MeshPart "Workspace.Enemies.Candy_Land.Hot_Choc_Mob_1.Plate". Thank you in advance

  • @therealkiddude
    @therealkiddude 2 года назад

    how do you make an animated one

  • @sirlarken
    @sirlarken 2 года назад

    all the tutorials didnt work, this didnt work but can you make a diffrent video that might help me and make it work?