Тёмный
No video :(

Roblox Enemy NPC Tutorial - Part 1 

MrModuleScript
Подписаться 1,9 тыс.
Просмотров 152 тыс.
50% 1

Want to make your own Enemy NPC in Roblox Studio?
This multi-part tutorial will be showing you how to create a NPC that chases the nearest player, damages the player, and has animations that are all customizable! Comments are welcomed!
Finished Model link: www.roblox.com...
Like if you like
Dislike if you dislike
Comment if you want to comment
Subscribe if you want to subscribe
And most importantly, script if you want to script :)

Опубликовано:

 

24 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 316   
@bonesReal
@bonesReal 2 года назад
A moment of silence for this man, he didn't have coffee this morning 😢 btw awesome tutorial my man
@SlothOfTheSea
@SlothOfTheSea 2 года назад
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!
@Charley1289
@Charley1289 Год назад
Same.
@Andrewdimaco
@Andrewdimaco 11 месяцев назад
Same @@Charley1289
@cookiezandcream5434
@cookiezandcream5434 8 месяцев назад
Same x2
@skyflyser9463
@skyflyser9463 Год назад
MrModuleScript:"Now we have to deal with a nil value in our heartbeat" bro thats dark
@rosesdavii
@rosesdavii Год назад
lol
@kontoarbuzowe6144
@kontoarbuzowe6144 Год назад
lol
@Charley1289
@Charley1289 Год назад
Oh.....
@RRT-
@RRT- Год назад
lol
@littlemowais3537
@littlemowais3537 26 дней назад
thank u for ur helpful tutorial , u just saved me hours of learning
@xb_desamaster8882
@xb_desamaster8882 7 месяцев назад
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_ 7 месяцев назад
can you text me the script it doesnt work for me
@lilfajita
@lilfajita 2 года назад
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
@coolcosmic4351
@coolcosmic4351 Год назад
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 3 месяца назад
Have u finished it yet ? what is ur user name
@coolcosmic4351
@coolcosmic4351 3 месяца назад
@@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 3 месяца назад
@@coolcosmic4351 mk
@alexanderhsl
@alexanderhsl Год назад
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.
@Pixelated173
@Pixelated173 Год назад
I would love to play this
@TyOstranderMMA
@TyOstranderMMA Год назад
yo how do you add more health
@bwshermanthenon-germansher6040
@@TyOstranderMMA health is inside the humanoid
@rafaelbrustolin4687
@rafaelbrustolin4687 Год назад
Im just starting to script and your tutorial helped me more than I could ever imagine
@mrmodulescript
@mrmodulescript Год назад
:D Glad to hear that!
@flamzy284
@flamzy284 Год назад
If it isn't moving make sure the torso or humanoidrootpart is unanchored
@DwarvenDoesThings
@DwarvenDoesThings Год назад
YES THIS WORKED!! THANK YOU!!
@Charley1289
@Charley1289 Год назад
I thought it would not work, like some of the other tutorials I tried, but this guys a legend!!!
@ESTE_CHILLZ
@ESTE_CHILLZ Год назад
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.
@ayobros7788
@ayobros7788 Год назад
Great Tutorial! So clear and works great. Keep it up
@BobSuper1
@BobSuper1 Год назад
Thank you so much! It took me forever to find a tutorial that i understand. You earned a like and a sub :)
@mrmodulescript
@mrmodulescript Год назад
Glad you found it helpful!
@oldsci82
@oldsci82 Год назад
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!
@Etohl
@Etohl Год назад
DUDE THANK YOU SO MUCH! I have been looking for hours for a script like this!
@Etohl
@Etohl 8 месяцев назад
@@URANUS113 Yes
@mommielala1853
@mommielala1853 Год назад
Thank u so much now my so know how to script on this game I will like and sub
@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!
@fhnine2698
@fhnine2698 2 года назад
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 года назад
Glad you got it working! Part 3 is on its way!
@EclipticBagelXD
@EclipticBagelXD Год назад
Yoo thanks for the tutorial! it helped me a lot :D
@gointorealheaven-jj5od
@gointorealheaven-jj5od 7 месяцев назад
Finally, a video that doesn't make me copy and paste the script
@yeeter6185
@yeeter6185 Год назад
For anyone what for R6 Rig Type (because this script not work on r6 type only r15) Note: It all rewrite by ChatGPT local RunService = game:GetService("RunService") local Players = game:GetService("Players") local humanoid = script.Parent local root = humanoid.Parent.Head 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.Head.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(direction) else humanoid:Move(Vector3.new()) end end end)
@FredButEvenWorse
@FredButEvenWorse Год назад
is it r6 or r15 bc i didn't understand what you said also it dosent work
@tugjames4528
@tugjames4528 2 года назад
I'm so happy this works with r6 as well
@JohnnyBoi08
@JohnnyBoi08 Год назад
incredibly useful tutorial, cant count the number of hours ive been trying to learn how to do this. Liekd and subscribed.
@pinhydroushere
@pinhydroushere Год назад
bro earned a sub faster than me looking for my dad
@sebalby34
@sebalby34 Год назад
8:37 bro direction is an absolute UNIT hehehehehehehehehehehehehehehhehehehehehhehhhehhe E E e e ᵉ ᵉ . . spiderman on his way home
@dababy3303
@dababy3303 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!
@Kjilness
@Kjilness Год назад
very epic and cool
@tateszabo9864
@tateszabo9864 Год назад
Epic video Didn't know a tutorial like this existed
@FireFuzzball673
@FireFuzzball673 Год назад
thank you are the only one that i found that does not do copy and paste
@spung0
@spung0 2 года назад
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 года назад
We just gotta hope he uploads more tutorials, the first 2 were helpful
@beanman2030
@beanman2030 Год назад
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'
@user-ct8gv7wm2o
@user-ct8gv7wm2o Год назад
just set the primary part of your model (usually HumanoidRootPart).
@storche211
@storche211 Год назад
@@user-ct8gv7wm2o Yep that was the problem, thank you.
@Thaierd
@Thaierd Год назад
This will really help with my friends game! Thanks alot!
@emiqus
@emiqus Год назад
thanks i watched this for a game with my friends :)
@arnabdutta1984
@arnabdutta1984 2 года назад
Just add the following line if r15 does not move root.Anchored = false
@jackforest8084
@jackforest8084 Год назад
Thank you so much! I knew i had an anchoring issue, i just did not know how to fix it.
@wunqo1
@wunqo1 Год назад
yoo broo, really apprechiate that you made this vid, also do you know how i could make the dummy walk faster?
@Crippley
@Crippley Год назад
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
@MisterPogman
@MisterPogman Год назад
how's it going for you?
@angelquefirestar
@angelquefirestar Год назад
This is really helpful for making a Partygoer in my Backrooms game!
@policeperson7589
@policeperson7589 8 месяцев назад
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
@opalova
@opalova Месяц назад
use script analysis and output
@bryanrojas6391
@bryanrojas6391 Год назад
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?
@Gameking1326_YT
@Gameking1326_YT 4 месяца назад
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.
@blinggaming7707
@blinggaming7707 Год назад
Does anyone know how to fix the error where it says that move is not a valid member of part?
@mrmodulescript
@mrmodulescript Год назад
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 Год назад
@@mrmodulescript OMG IT WORKED BRO TYSM!
@blinggaming7707
@blinggaming7707 Год назад
@@mrmodulescript IM MAKING A HORROR GAME SO THIS WILL HELP A LOT
@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
@andrewtriffett331
@andrewtriffett331 Год назад
thank you
@tobiasleijdesdorff9960
@tobiasleijdesdorff9960 2 года назад
Thanks For The Video!
@B_duzzle
@B_duzzle Год назад
can I use r6 dummy?
@Charley1289
@Charley1289 Год назад
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!!
@tikel5563
@tikel5563 Год назад
Thank you so much for a legit script that works very nicely!
@aarthisakthivel1028
@aarthisakthivel1028 7 месяцев назад
this is the birth of the student enemy for me
@deku972
@deku972 10 месяцев назад
You are a w man this will help me so much thank you🙂
@joshcaskey9485
@joshcaskey9485 Месяц назад
I can't figure out why my custom rig isn't working with the Script
@Charley1289
@Charley1289 Год назад
I Subscribed!
@tiendrip-han6458
@tiendrip-han6458 Месяц назад
W video bro.
@gabrielccbr1
@gabrielccbr1 11 месяцев назад
ty hehe
@kyledelosreyesmontemayor5008
@kyledelosreyesmontemayor5008 7 часов назад
Torso. Unanchored. HumanoidRootPart. Unanchored. Script. No errors. Still couldnt move. The only thing that was anchored was the Humanoid.
@mikarolls
@mikarolls Год назад
thank you! :D
@pistolgames232
@pistolgames232 2 года назад
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 года назад
just set their root CFrame to the span location CFrame after the player is outside the distance.
@BushWithAGun
@BushWithAGun 2 года назад
idk how to do that tho
@calebetheredge9307
@calebetheredge9307 Год назад
can you make a tutorial so that we can make a mesh with a humanoid in it attack you instead of a dummy
@Devil_edits_op
@Devil_edits_op Год назад
why does the end ()) has a wrong in it ? Runservice.Heartbeat:Connect(function() local nearestplayer, distance, direction = FindNearestPlayer() if nearestplayer then if distance = stopDistance then humainoid:Move(direction) else humainoid:Move(Vector3.new()) end end)
@PolyVein
@PolyVein 2 года назад
How would i add animations to this?
@Okehynot1880
@Okehynot1880 6 месяцев назад
I wanna make an npc like this that is friendly if you have a specific item or a specific team
@LordPaijo
@LordPaijo Год назад
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.
@darealspiker
@darealspiker Год назад
Do not talk to me until I have my morning coffee
@andrewdaniels6792
@andrewdaniels6792 Год назад
``if not nearestPlayer or distanceVector.Magnitude < distance then``
@byuulahn9331
@byuulahn9331 2 года назад
after I downloaded the dummy it kept spawning in every of my baseplates. How can you make it stop?
@mykidneyhurts1372
@mykidneyhurts1372 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
@koreyDoreyASG
@koreyDoreyASG Год назад
You deserve more subs
@mrmodulescript
@mrmodulescript Год назад
AHHH IM SORRY HERE IT IS I JUST RELEASED IT
@user-lm9me5oo9l
@user-lm9me5oo9l Месяц назад
i cant do it its to hard for me :(
@randomgamesofcreativity
@randomgamesofcreativity Год назад
thank you
@SushiBeeReal
@SushiBeeReal Год назад
I have a problem, my characters that I added aren't taking damage from anything, does anyone have a fix
@iamgameing3840
@iamgameing3840 Год назад
there a way to make it only target you when you're on a certain team?
@codrin6772
@codrin6772 Год назад
It gives me an error: "Workspace.StarterCharacter.EnemyController:20: attempt to index nil with 'Position' - Server" Can anyone help me?
@2THURLGHXST
@2THURLGHXST 5 месяцев назад
when i use a kickback move it completely flys away
@champthechimp
@champthechimp Год назад
If you followed the instructions perfectly but it still doesn't work, MAKE SURE THE SCRIPT IS IN THE HUMANOID, not just in the model!
@ImAPersonHehehehaw
@ImAPersonHehehehaw 8 месяцев назад
Thank you!
@macstorm2234
@macstorm2234 2 года назад
Part 1 results : How to make a "peacefull" enemy npc
@KaliStiix
@KaliStiix Год назад
Well you add a kill script, modify the damage and done That what I did with a npc
@macstorm2234
@macstorm2234 Год назад
@@KaliStiixThats the part 2
@wethebest-obamiumcore1457
@wethebest-obamiumcore1457 2 года назад
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
@WRYYYYYYYY0629
@WRYYYYYYYY0629 2 года назад
Use robloxpathfinderservice
@Firedragon8544
@Firedragon8544 Год назад
nice work i love it but its easyer if we could copy and past
@paulwhidborne1982
@paulwhidborne1982 15 дней назад
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
@FuzzyDev
@FuzzyDev Год назад
Thanks!
@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
@user-hu8fp2ep9b
@user-hu8fp2ep9b 2 года назад
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
@Ðogecoin
@Ðogecoin Год назад
Thank you
@thechannel7988
@thechannel7988 Год назад
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
@RipTai
@RipTai Год назад
do i have to put it to nil or some other name?
@Iceless_0
@Iceless_0 2 года назад
Will there be a second part? subbed btw
@mrmodulescript
@mrmodulescript 2 года назад
In the process of finishing it! Just have to finish the last parts of editing the video. Thanks!
@Wivern-doppleganger360
@Wivern-doppleganger360 Месяц назад
Remember to put the script in the humanoid guys
@darkbard7
@darkbard7 Месяц назад
make one with that finding plz
@ImAPersonHehehehaw
@ImAPersonHehehehaw 8 месяцев назад
I put everything correctly but the npc won’t move
@ablaabl8315
@ablaabl8315 Год назад
(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?
@Freddie_Office
@Freddie_Office 2 года назад
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
@wooega
@wooega Год назад
Could you also make dummy that helps you in a battle
@Solo_Guy360
@Solo_Guy360 Год назад
everytime i try the npc in studio and click play, there are hundreds of dummys on top of me, please help!
@bzghosbz9038
@bzghosbz9038 3 месяца назад
is he able to like know that theres an object infront of him can go past stuff or just get stuck?
@Cheese45542
@Cheese45542 Год назад
they dont do anything even though i get no errors i tried both r6 and r15 and it doesnt want to work
@WildPickle
@WildPickle Год назад
this is useful but could you at some point make one for models, not the normal dummy.
@calcumalations1235
@calcumalations1235 Год назад
Yo when I play it says “Character is. Not a valid member of Players “Players”
@reference1-2
@reference1-2 Год назад
Cool
@mrmodulescript
@mrmodulescript 2 года назад
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!
@Ace_L_real
@Ace_L_real 3 месяца назад
can you make it stop after being to far away like the chasing is a range?
@theguywhosinred
@theguywhosinred 5 месяцев назад
how do you give the npc health i watched all parts but like no hp!!!!
@Math_IGuess
@Math_IGuess Год назад
i need an enemy that walks while you on roblox studio
Далее
Roblox Enemy NPC Tutorial - Part 2
15:05
Просмотров 47 тыс.
The Most Impressive Scratch Projects
11:00
Просмотров 4,9 млн
Why I Hate Roblox Abilities
11:52
Просмотров 380 тыс.
Reading YOUR Discord Mod Applications 2
13:25
Просмотров 2,3 млн
Can AI Code a Horror Game? Watch ChatGPT Try
8:06
Просмотров 1,1 млн
Can I Make a Roblox Game With ZERO Code?
12:02
Просмотров 65 тыс.
Making My Roblox Game VIRAL in 24 HOURS
9:24
Просмотров 31 тыс.
Making a ROBLOX game with its new AI
6:28
Просмотров 750 тыс.
(Moon Animator) Impact Frames: Basic Tutorial
9:20
Просмотров 357 тыс.
Essential UI Tips & Tricks | Roblox Studio
9:19
Просмотров 47 тыс.
I tried to make a Valorant AI using computer vision
19:23