Тёмный

How to Make an Enemy NPC in Roblox Studio 2024! 

DevMelon
Подписаться 2,2 тыс.
Просмотров 16 тыс.
50% 1

Hey guys! In todays video I teach you how to make an Enemy NPC which chases you and attacks which can be used for many games and is very fun to play around with!
How to Make a Working ENEMY NPC in ROBLOX STUDIO!
SUBSCRIBE HERE! ➜ / @devmelonroblox
Be sure to hit the bell to turn on notifications!
Be sure to hit that like button!
Join my Roblox Group here: www.roblox.com/groups/9221251...
Join my discord here: / discord
#roblox​​ #robloxscripting #robloxstudio
Timecodes
0:00 - Intro
0:49 - Rig
1:15 - Scripting
5:50 - Outro
How to Make a Working ENEMY NPC in ROBLOX STUDIO!How to Make a Working ENEMY NPC in ROBLOX STUDIO!f

Игры

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

 

15 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 151   
@devmelonroblox
@devmelonroblox 4 месяца назад
Thanks for watching! If you enjoyed make sure to like and also comment any suggestions below!
@tuh_reptile
@tuh_reptile 2 месяца назад
Can you make another video like this but with a more advanced ai? (e.g moving around parts) It would really help!
@silkesolke
@silkesolke 2 месяца назад
Is this for r6 too??
@fevineslegend
@fevineslegend 2 месяца назад
How to put script in description of a devmelon video tutorial
@JumpyMan204
@JumpyMan204 Месяц назад
Yeeeeeee NICE VIDEO!
@The_Ace_Debate
@The_Ace_Debate 29 дней назад
how do you make it to where it only chases you when in a certain range
@BlueWithaFruit
@BlueWithaFruit 4 месяца назад
script: local NPC = script.Parent local HumanoidRootPart = NPC.HumanoidRootPart local MaxDistance = math.huge local debounce = false NPC.Humanoid.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not debounce then debounce = true hit.Parent.Humanoid.Health -= 20 wait(1) debounce = false end end) while wait() do local Players = game.Players:GetPlayers() local closest for i, plr in pairs(Players) do if plr.Character and plr.Character:FindFirstChild("Humanoid") and plr.Character.Humanoid.Health > 0 then local PlayerHumanoidRootPart = plr.Character.HumanoidRootPart local Distance = (HumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude if not closest then closest = PlayerHumanoidRootPart end if (HumanoidRootPart.Position - closest.Position).Magnitude > Distance then closest = PlayerHumanoidRootPart end end end if closest and (HumanoidRootPart.Position - closest.Position).Magnitude
@danielcoolguy2465
@danielcoolguy2465 4 месяца назад
you saved me from finding a typo
@JustCallMeBurntToast
@JustCallMeBurntToast 3 месяца назад
OMG BRO TYSM I WAS TRYING TO SEARCH FOR A TYPO FOR 30 MIN BUT U SAVED ME
@PortableContent
@PortableContent 3 месяца назад
you just saved my keyboard bro 😂
@thatyoutubeguy-md2ws
@thatyoutubeguy-md2ws 2 месяца назад
Thank You!!!
@AminSaler
@AminSaler 2 месяца назад
THANK YOU SO MUCH BRO
@deathdoesroblox
@deathdoesroblox 4 месяца назад
Awesome video! Very Helpful and insightful
@devmelonroblox
@devmelonroblox 4 месяца назад
Glad it was helpful!
@mr_angel_potat
@mr_angel_potat 2 месяца назад
bruh finally a scipt that ACUALLY WORKED thx devmelon you helped me ALOT
@mrgoodman7837
@mrgoodman7837 4 месяца назад
the best of all the devs. love the work dev melon.
@devmelonroblox
@devmelonroblox 4 месяца назад
Thank you good sir
@SunsetVR21
@SunsetVR21 3 месяца назад
Ty so much this will help me a lot with the game that I'm making!❤
@Tuxedox
@Tuxedox 4 месяца назад
w video bro keep it up
@devmelonroblox
@devmelonroblox 4 месяца назад
Thanks!
@JumpyMan204
@JumpyMan204 Месяц назад
hey man i just came here to tell u that u that ur videos are useful, funny, and informative 🤓🤓🤓 but jokes aside u actually need more than 1.9k subs
@devmelonroblox
@devmelonroblox Месяц назад
Thanks
@greemp
@greemp 2 месяца назад
devmelon thank you and i subscribe you. can you make a video about the hiding system from the enemy?
@WhartonProject
@WhartonProject 4 месяца назад
Can you make it so you get a leaderstat/variable when you kill it
@TizianoNicolasGamer100
@TizianoNicolasGamer100 3 дня назад
looking good, devmelon but it's better when it has attack animations so the enemy npc would be epic.
@deathreaper4200
@deathreaper4200 4 месяца назад
thank you so much
@digipug
@digipug 3 месяца назад
Finally a script that works I have looked trough so many tutorials and they have just been filled with people that cant speak properly and they also dont teach you anything they just say copy this script that I have linked in the description.
@clopheritearchive
@clopheritearchive 10 дней назад
You're fr one of the best Roblox Devs on RU-vid right now.
@devmelonroblox
@devmelonroblox 10 дней назад
Thanks!
@MasterGamer_122YT
@MasterGamer_122YT 3 месяца назад
How would i make it immortal or something like that bc if i put 2 they kill eachother
@TTVtreekoVr
@TTVtreekoVr 20 дней назад
Pleaseee, your videos are amazing but I had problems with this one, I used a rig from the toolbox of sonic exe and it only does damage when I touch him but he doesn’t chase.. what do I do. Was it bc I didn’t do the same rig as you or no..? I just really need to figure it out. Please and thank you🙏
@devmelonroblox
@devmelonroblox 20 дней назад
Do you get any errors in your script?
@TTVtreekoVr
@TTVtreekoVr 16 дней назад
@@devmelonrobloxno, but does it matter that I didn’t animate it and only copy and pasted the animate script?
@KingLlama432
@KingLlama432 2 месяца назад
i made my own custom modle but it wont move it only follows my direction
@Igrowtreesforlife
@Igrowtreesforlife Месяц назад
Someone help me it’s not working and the output says there are no errors
@Mr.Outlet1
@Mr.Outlet1 Месяц назад
I tried to do the chase script and after i was done it didnt work i do think it had something to do line 37 where you had “if Closest and (HumanoidRootPart.Position - Closest.Position).Magnitude
@HatInInternet
@HatInInternet 7 дней назад
U have output windows opened? If you're not getting any errors, try putting print("test") in your script and see if it prints it.
@Akino_Artist
@Akino_Artist 2 месяца назад
finaly someone explaining the script not just giving it to us to copy it thanksss
@devmelonroblox
@devmelonroblox 2 месяца назад
Thansk!
@kadsian539
@kadsian539 2 месяца назад
what about adding an animation to it with cooldowns
@ERICNETIC_pubgm
@ERICNETIC_pubgm Месяц назад
How do you make it so that multiple npcs dont kill each other but kill you only
@devmelonroblox
@devmelonroblox Месяц назад
You can name them all one name and where it checks for humanoid you can do if name ~= “name of npc”
@EricChawira
@EricChawira Месяц назад
@@devmelonrobloxcan u explain in more detail
@StupidMiners
@StupidMiners 2 месяца назад
I have a small question. I made a bunch of enemies but i don't want them to attack each other. However I don't really know how to fix that so could you make a video on how to make that?
@HanaaMajdrazane
@HanaaMajdrazane 29 дней назад
Thanks
@BushiX5
@BushiX5 2 месяца назад
Thanks❤ and how do you replace the animations with different ones?
@devmelonroblox
@devmelonroblox 2 месяца назад
Yopu check the naimation script and there will be the run id in there youll find it
@LincZz
@LincZz День назад
Hey. idk if ur gonna see this but how do I make a custom model of the AI
@coreonstyx
@coreonstyx Месяц назад
my npc isnt moving any advice?
@AxelResendez546
@AxelResendez546 15 дней назад
Same
@P4nM4nC0der
@P4nM4nC0der 13 дней назад
It could be anchored, try unanchoring it
@coreonstyx
@coreonstyx 13 дней назад
@@P4nM4nC0der ok
@TheGuyThatKnewThe
@TheGuyThatKnewThe 4 месяца назад
NO WAY! This is amazing. YOU literally read my mind. I was looking for the perfect video, and i think i found it! Thanks so much!
@devmelonroblox
@devmelonroblox 4 месяца назад
You're so welcome!
@SafeOfArsenal
@SafeOfArsenal 6 дней назад
is it possible to make a safe zone where the npc wont go inside of?
@thecubeheadguy6747
@thecubeheadguy6747 3 месяца назад
my npc just teleports at me for some reason. I even set its walkspeed to 10
@BushiX5
@BushiX5 2 месяца назад
I made multiple and the enemy NPCs hurt eachother pls help
@DaLemonMonke158
@DaLemonMonke158 Месяц назад
Hey thanks for helping me with my game! (your prob not going to see this) but how can i make it so the rig will chase after a player when its near them? thanks for helping me with my game and i hope you have the time to respond
@devmelonroblox
@devmelonroblox Месяц назад
Hey! I think I. Will make a renewed version of the tutorial but there’s a way of checking the distance between the player and the dummy and checking if it’s lower
@devmelonroblox
@devmelonroblox Месяц назад
It’s quite hard to explain in comments
@DaLemonMonke158
@DaLemonMonke158 Месяц назад
Oh wow you actually did respond! That’s fine though I will try my best!
@devmelonroblox
@devmelonroblox Месяц назад
@@DaLemonMonke158 ofc! Good luck with ur game
@BlueWithaFruit
@BlueWithaFruit 4 месяца назад
How would i be able to change the max distance, like if you were in a certain range it would follow you
@devmelonroblox
@devmelonroblox 4 месяца назад
You set the max distance on the script
@Rushing-know
@Rushing-know 3 месяца назад
@@devmelonroblox could i do local maxDistance = 10 ?
@autorade69420
@autorade69420 2 месяца назад
how do i make them respawn?
@jorgeahernandez1212
@jorgeahernandez1212 Месяц назад
how do I make it pathfinding???
@bob-nh5qg
@bob-nh5qg Месяц назад
how would i make the detection range of the enemy lower (im making a castle i only want it to follow you when you go in)
@gdzh
@gdzh 19 дней назад
if you know tell me
@bob-nh5qg
@bob-nh5qg 18 дней назад
@@gdzh i found out but i can't put the full thing in the comments cuz it doesn't go through
@gdzh
@gdzh 18 дней назад
@@bob-nh5qgok😢
@Random_Idiot69420
@Random_Idiot69420 22 дня назад
How do I make it so they don't FRICKIN ATTACK EACHOTHER
@JumpyMan204
@JumpyMan204 Месяц назад
devmelon: and it will-.. and it will allow-.. and it will allow you-... and it will allow the NPC to damage you.
@devmelonroblox
@devmelonroblox Месяц назад
😭
@mrbob7891
@mrbob7891 13 дней назад
plsssss help u didnt make a code for allowing him to die
@2lmao2
@2lmao2 4 месяца назад
youre literally my roblox studio teacher lmao
@devmelonroblox
@devmelonroblox 4 месяца назад
Ahahah
@CarLover33384
@CarLover33384 4 месяца назад
fr
@ExtremeShadow
@ExtremeShadow 4 месяца назад
Hey devmelon! I watched your tutorial on how to make a difficult chart obby and it really helped! How did you learn code? I want to learn lua too but I cant learn it. Its too hard.
@devmelonroblox
@devmelonroblox 4 месяца назад
I think I learned by watching dev kings beginner tutorials
@NaiveSchmidt
@NaiveSchmidt Месяц назад
Does this work in R6?
@ZachariasTheGreat_
@ZachariasTheGreat_ 2 месяца назад
Is there any way to add a range of agro for the rig so it does t attack me from anywhere?
@malvinmahendra7356
@malvinmahendra7356 2 месяца назад
change the math.huge on the MaxDistance into any number you want, that works for me
@thatonehelperdude-vj8rp
@thatonehelperdude-vj8rp 4 месяца назад
you can use a script of a zombie
@gigamario9056
@gigamario9056 3 месяца назад
Its not working idk what to do
@daveiscool24
@daveiscool24 Месяц назад
It worked the first time but when I colored it it stopped working
@devmelonroblox
@devmelonroblox Месяц назад
Make sure you spelled everything correctly
@The_ShyGuy64
@The_ShyGuy64 3 месяца назад
It works well unless more than 1 npc is near eachother, then they will kill eachother
@devmelonroblox
@devmelonroblox 3 месяца назад
You can add a code so that it doesn’t follow if the persons name is npc and name all the npcs npc
@autorade69420
@autorade69420 2 месяца назад
@@devmelonrobloxhow to do that?
@terezaopatril8966
@terezaopatril8966 2 месяца назад
it didn't work I tried to fix it but it didn't work
@bananakid8270
@bananakid8270 3 месяца назад
Hey devmelon ive tried typing the script that you did in the video and it doesn't seem to work so idk what i did wrong.
@xlives23
@xlives23 4 дня назад
local NPC = script.Parent local HumanoidRootPart = NPC.HumanoidRootPart local MaxDistance = math.huge local debounce = false NPC.Humanoid.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not debounce then debounce = true hit.Parent.Humanoid.Health -= 20 wait(1) debounce = false end end) while wait() do local Players = game.Players:GetPlayers() local closest for i, plr in pairs(Players) do if plr.Character and plr.Character:FindFirstChild("Humanoid") and plr.Character.Humanoid.Health > 0 then local PlayerHumanoidRootPart = plr.Character.HumanoidRootPart local Distance = (HumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude if not closest then closest = PlayerHumanoidRootPart end if (HumanoidRootPart.Position - closest.Position).Magnitude > Distance then closest = PlayerHumanoidRootPart end end end if closest and (HumanoidRootPart.Position - closest.Position).Magnitude
@gabrielafierrolara9866
@gabrielafierrolara9866 День назад
oye por que a mí no me funciona?
@BiscuitIsUrFriend
@BiscuitIsUrFriend Месяц назад
1:56 yo were you ok?
@DapperGapperTheYapper
@DapperGapperTheYapper 13 дней назад
please help me it didnt work my error is "humanoid is not a valid member of Model "Workspace.Grandpa" and yes the name of my rig is grandpa
@DapperGapperTheYapper
@DapperGapperTheYapper 13 дней назад
Nvm i got it
@devmelonroblox
@devmelonroblox 13 дней назад
@@DapperGapperTheYapper yesss!!!!
@user-smal_-games
@user-smal_-games Месяц назад
How we can kill them?
@deathreaper4200
@deathreaper4200 4 месяца назад
dude its moving but not damaging me
@Nick-445.
@Nick-445. 3 месяца назад
Vid starts at 2:00
@devmelonroblox
@devmelonroblox 3 месяца назад
Lol yes there are timeframes i think
@declanconway7966
@declanconway7966 2 месяца назад
The animation isn't working for me, but I did as showed.
@devmelonroblox
@devmelonroblox 2 месяца назад
Which animation did you use?
@declanconway7966
@declanconway7966 2 месяца назад
@@devmelonroblox I just copy and pasted the one that was already in the rig
@That_1Pumpkin
@That_1Pumpkin 2 месяца назад
Does this work with R6
@devmelonroblox
@devmelonroblox 2 месяца назад
Yes
@chaseavery2586
@chaseavery2586 29 дней назад
but i hate R15 i use R6
@zmigal
@zmigal 4 месяца назад
firist
@devmelonroblox
@devmelonroblox 4 месяца назад
Crazy
@ImNinjaNick
@ImNinjaNick Месяц назад
for some reason it did not work for me 😥
@devmelonroblox
@devmelonroblox Месяц назад
Do you get any errors?
@ImNinjaNick
@ImNinjaNick Месяц назад
@@devmelonroblox no it just does not work idk whats wrong with it
@IlIIlIlllIlII
@IlIIlIlllIlII 2 месяца назад
how do i can change distance?
@malvinmahendra7356
@malvinmahendra7356 2 месяца назад
change the math.huge on the MaxDistance into any number you want
@IlIIlIlllIlII
@IlIIlIlllIlII 2 месяца назад
@@malvinmahendra7356 hey, ty
@theawesomechannel6563
@theawesomechannel6563 3 месяца назад
It didnt work
@things4438
@things4438 19 дней назад
right when i gain motivation again to work on my game MY FREAKING (and im resisting to not say another word) STUDIO IS FREAKING BROKEN, BUILT IN PLUGINS DOES NOT WORK, I TRIED EVERYTHING AND NO CHANGES, NO ONE TALKS ABOUT IT ON THE DEVFORUM, AND BECAUSE OF THAT FREAKING TRUST THING I CANT FREAKING MAKE A POST FRICK ROBLOX
@devmelonroblox
@devmelonroblox 18 дней назад
Try uninstalling and reinstalling roblox studio!
@things4438
@things4438 18 дней назад
@@devmelonroblox never though you will answer lol, i got a little bit mad, but yes i uninstalled it, didnt worked, so i manually deleted the entire roblox folder, did not worked too
@devmelonroblox
@devmelonroblox 18 дней назад
@things4438 that’s really strange what
@CarLover33384
@CarLover33384 4 месяца назад
didnt work :/
@CarLover33384
@CarLover33384 4 месяца назад
im sad now i needed it :(
@CarLover33384
@CarLover33384 4 месяца назад
Yours is the only good looking one
@devmelonroblox
@devmelonroblox 4 месяца назад
Do you get any errors?
@MeteoritePlays
@MeteoritePlays Месяц назад
did not work
@HatInInternet
@HatInInternet 7 дней назад
Skill issue
@MeteoritePlays
@MeteoritePlays 6 дней назад
@@HatInInternet you are trash
@thatyoutubeguy-md2ws
@thatyoutubeguy-md2ws 10 дней назад
I have a better version of this were when the npc dead it does not attack and after 4 secs the npc destroys. Script: local NPC = script.Parent local HumanoidRootPart = NPC.HumanoidRootPart local Died = false local MaxDistance = math.huge local debounce = false NPC.Humanoid.Died:Connect(function() Died = true wait(4) NPC:Destroy() end) NPC.Humanoid.Touched:Connect(function(hit) if Died == true then return end if hit.Parent:FindFirstChild("Humanoid") and not debounce then debounce = true hit.Parent.Humanoid.Health -= 20 wait(1) debounce = false end end) while wait() do local Players = game.Players:GetPlayers() local closest for i, plr in pairs(Players) do if plr.Character and plr.Character:FindFirstChild("Humanoid") and plr.Character.Humanoid.Health > 0 then local PlayerHumanoidRootPart = plr.Character.HumanoidRootPart local Distance = (HumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude if not closest then closest = PlayerHumanoidRootPart end if (HumanoidRootPart.Position - closest.Position).Magnitude > Distance then closest = PlayerHumanoidRootPart end end end if closest and (HumanoidRootPart.Position - closest.Position).Magnitude
@WildGamer0
@WildGamer0 17 дней назад
Lies never even moves
@devmelonroblox
@devmelonroblox 17 дней назад
@@WildGamer0 bro at least tell me ur error that you get in the output💀
@devmelonroblox
@devmelonroblox 17 дней назад
Instead of saying that I’m lying
@WildGamer0
@WildGamer0 17 дней назад
@@devmelonroblox sorry I just got rly mad, the error was that it literally wasn’t even moving
@devmelonroblox
@devmelonroblox 17 дней назад
@@WildGamer0 Do you get any erorr in the OUTPUT
@WildGamer0
@WildGamer0 16 дней назад
Ohhh, it’s the same error that occurred for you at 5:01 I just didn’t watch it all I thought it was done when you play tested. Apology’s😅🙏
Далее
Roblox Enemy NPC Tutorial - Part 1
18:49
Просмотров 149 тыс.
Coding realistic water physics into roblox…
8:50
Просмотров 313 тыс.
I Spent 24 Hours to beat Roblox's Smartest NPC
9:36
Просмотров 637 тыс.
Making a Genuinely Scary Roblox Horror Game
5:56
Просмотров 48 тыс.
Classic Roblox Games: How Are They Doing?
17:09
Просмотров 214 тыс.
I Learned How to SCRIPT in 7 Days | Roblox
11:00
Просмотров 45 тыс.
I Paid Devs on Fiverr to Make an Open World Game
8:33
Просмотров 161 тыс.
I Made FAKE GAME To Trap HACKERS.. It WORKED! (Roblox)
12:27
Can AI Code a Horror Game? Watch ChatGPT Try
8:06
Просмотров 1,1 млн
The Fall of Roblox's Biggest Games
16:48
Просмотров 4,4 млн
МЕТРО ПАБГ СОЛО СКВАД
4:0:04
Просмотров 56 тыс.