How to Make an Enemy NPC in Roblox Studio 2024!

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

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

  • @devmelonroblox
    @devmelonroblox  10 месяцев назад +23

    Thanks for watching! If you enjoyed make sure to like and also comment any suggestions below!

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

      Can you make another video like this but with a more advanced ai? (e.g moving around parts) It would really help!

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

      Is this for r6 too??

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

      How to put script in description of a devmelon video tutorial

    • @JumperPlaysRoblox
      @JumperPlaysRoblox 7 месяцев назад +1

      Yeeeeeee NICE VIDEO!

    • @The-Ace-Animator
      @The-Ace-Animator 7 месяцев назад

      how do you make it to where it only chases you when in a certain range

  • @BlueWithaFruit
    @BlueWithaFruit 10 месяцев назад +271

    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

  • @deathdoesroblox
    @deathdoesroblox 10 месяцев назад +10

    Awesome video! Very Helpful and insightful

    • @devmelonroblox
      @devmelonroblox  10 месяцев назад +3

      Glad it was helpful!

    • @Ipad_cat
      @Ipad_cat Месяц назад +1

      Wait death ur here too?!🤓

  • @Akino_Artist
    @Akino_Artist 8 месяцев назад +17

    finaly someone explaining the script not just giving it to us to copy it thanksss

  • @JohnaldStudios
    @JohnaldStudios Месяц назад +2

    Note to those that might be encountering an issue where the npc won't move despite the entire script being typed in: Make sure to drag ChaseScript onto Rig

  • @Tuxedox
    @Tuxedox 10 месяцев назад +6

    w video bro keep it up

  • @WhartonProject
    @WhartonProject 10 месяцев назад +4

    Can you make it so you get a leaderstat/variable when you kill it

  • @FlameyClockspeed
    @FlameyClockspeed 3 дня назад +1

    How can you make it so one npc attacks another NPC thats on another team

    • @FlameyClockspeed
      @FlameyClockspeed 3 дня назад

      I managed to stitch together a working script for my request

  • @Ghostly_Rblx
    @Ghostly_Rblx 10 месяцев назад +3

    How would i make it immortal or something like that bc if i put 2 they kill eachother

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

      I'm probably of no help 4 months later, but if you go into the Rig > Humanoid, then into the Humanoid properties, and scroll down to Game, there is MaxHealth, which in short term can help if you give it a really high number
      Edit: I tried creating a code, which I suck atAnd I couldn't get it to work. AI helped make this (which I wrote most of.) Try reading already existing codes and sometimes Studio will help but you can always ask AI which I found is an amazing tool for learning code.
      Just put the script in the Humanoid space and give the Rig a name so you can keep track of them. I chose "Rig1" as the name and where Rig1 is in the code, replace with what you want. I also added some yapping so you can make some sense of it... hopefully
      -------------------------------------------------------------------
      local humanoid = workspace.Rig1.Humanoid
      if humanoid.MaxHealth < 100 then
      humanoid.MaxHealth = 100
      end ---It is saying if the max health is less than 100 (The max value), it is equal to 100
      while true do --While that is true (That it is less than 100 and SHOULD be equal to 100)
      if humanoid.Health < humanoid.MaxHealth then --if the health of the humanoid is less than the max health
      humanoid.Health = humanoid.MaxHealth --It is set to equal max health
      end
      wait(1)--wait 1 second to repeat which should be enough, but I heard it is possible for wait code to be laggy if there are a lot
      end

  • @mrgoodman7837
    @mrgoodman7837 10 месяцев назад +1

    the best of all the devs. love the work dev melon.

  • @clopheritearchive
    @clopheritearchive 6 месяцев назад +4

    You're fr one of the best Roblox Devs on RUclips right now.

  • @BlueWithaFruit
    @BlueWithaFruit 10 месяцев назад +2

    How would i be able to change the max distance, like if you were in a certain range it would follow you

    • @devmelonroblox
      @devmelonroblox  10 месяцев назад +2

      You set the max distance on the script

    • @Rushing-know
      @Rushing-know 9 месяцев назад +1

      @@devmelonroblox could i do local maxDistance = 10 ?

    • @Cravy_MC
      @Cravy_MC 3 месяца назад +1

      @@Rushing-know yes

  • @starblaze0
    @starblaze0 4 месяца назад +3

    Hey, your script works perfectly with running and chasing the player, but how do i make the npc to jump over the obstacles? Im just new to scripting so sorry if its a stupid question

  • @CreamyHappy
    @CreamyHappy Месяц назад +5

    Bro, I can't work, I've been trying for an hour but everything I've done has failed, everything I've done has failed😢

  • @MentalySlow
    @MentalySlow 10 месяцев назад +3

    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!

  • @20_cents
    @20_cents Месяц назад +1

    When you kill the npc hes body stays there , it takes damage when someone walks over it , how do I make him desapear after death??!!?!

    • @MrJackeeper
      @MrJackeeper Месяц назад +2

      Just Added New script And write this
      local Npc = script.Parent
      local hum = Npc:FindFirstChild("Humanoid")
      hum.Died:Connect(function()
      wait(2)
      Npc:Destroy()
      end)

    • @20_cents
      @20_cents Месяц назад

      @@MrJackeeper Thanks a lot :D

  • @LastReelX
    @LastReelX 6 месяцев назад +4

    Thank you so much, it actually works. One question though, if there are multiple of these rigs that keep attacking each other instead of the player, how do I make it so they don't attack each other. If you give an answer ill subscribe

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

      @@LastReelX check in the chasing and damage script if the name of hit.Parent or target is not the name of the npc

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

      you can do if game.Players:FindFirstChild(hit.Partent.Name) then
      that should work

  • @2lmao2
    @2lmao2 10 месяцев назад +3

    youre literally my roblox studio teacher lmao

  • @Greatlymatthew
    @Greatlymatthew 7 месяцев назад +5

    How do you make it so that multiple npcs dont kill each other but kill you only

    • @devmelonroblox
      @devmelonroblox  7 месяцев назад

      You can name them all one name and where it checks for humanoid you can do if name ~= “name of npc”

    • @luhrih
      @luhrih 7 месяцев назад

      @@devmelonrobloxcan u explain in more detail

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

      i think what he’s trying to say is u need to add in a line ( or part of the same line) that also checks the name of the parent of the “humanoid” part and make sure that the name of the parent isn’t *insert name of npc*

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

      but idk i tried changing the line to "if hit.Parent:FindFirstChild("Humanoid") and not debounce and not hit.Parent:GetFullName("*insert name*") then" and it didn't do anything

    • @Ceve01
      @Ceve01 4 месяца назад +2

      Made my own changes in the code that seems to work, starting from line 8:
      NPC.Humanoid.Touched:Connect(function(hit)
      if hit.Parent.Name ~= "Name of your npc:s" then
      if hit.Parent:FindFirstChild("Humanoid") and not Debounce then
      Debounce = true
      hit.Parent.Humanoid.Health -= 20
      wait(1)
      Debounce = false
      end

      end

      end)
      If hit.parent (The rig) doesn't have the npc:s name. Then it's able to kill it. Just remember to keep the quotation marks and it will hopefully work!

  • @mrbob7891
    @mrbob7891 6 месяцев назад +4

    plsssss help u didnt make a code for allowing him to die

  • @decngeorge8428
    @decngeorge8428 21 день назад +2

    i tried to do it but it didn't work to well,it only took damage

  • @Borneliuss
    @Borneliuss Месяц назад +3

    beautiful intro

  • @TTVtreekoVr
    @TTVtreekoVr 7 месяцев назад +3

    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  7 месяцев назад

      Do you get any errors in your script?

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

      @@devmelonrobloxno, but does it matter that I didn’t animate it and only copy and pasted the animate script?

  • @DevBimon69
    @DevBimon69 8 дней назад

    this awesome! defenitly deserve more subscribers

  • @Sturdy_Monke
    @Sturdy_Monke 3 месяца назад +1

    How do I make it so that when the npc dies it stops dealing damage?

  • @JuanDeathJaw
    @JuanDeathJaw 21 день назад +1

    Hey Devmelon, i really enjoyed your help and script, however whenever i destroy the npc the parts do not disappear, i need help with this because its causing my games to crash

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

    TYSM! i was making a game based on my school lunch moniter and she puts us through hell everyday and my buddies told me to make a scary roblox game abt her so i took a good accurate cosplay of her and made the killer NPC with this tut and now i have scary roblox game!!!! THANK YOU SO MUCH I WOULDNT BE ABLE TO DO THIS WITHOUT YOU!!!!!!!

  • @mr_angel_potat
    @mr_angel_potat 8 месяцев назад +2

    bruh finally a scipt that ACUALLY WORKED thx devmelon you helped me ALOT

  • @Beastboy-kawaii
    @Beastboy-kawaii Месяц назад +2

    my enemy npcs keep killing each other and then when u touch them their remains hurt u HELP

    • @Demonic_Entity-h4t
      @Demonic_Entity-h4t Месяц назад

      you could instead do a script to where it Destroy()'s the body parts of the npc upon death, not sure if it may work but try it if all else fails

  • @Mr.Outlet1
    @Mr.Outlet1 7 месяцев назад +2

    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 6 месяцев назад

      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.

    • @spam-jesus_e
      @spam-jesus_e Месяц назад

      He put it in the wrong place then he moved it down

  • @RamboHAZ
    @RamboHAZ 15 дней назад

    THANKS SO MUCH, i think this is the only tutorial that works and gives animation to it. tysm + 1 sub

  • @ZeoNeo-123
    @ZeoNeo-123 3 месяца назад +2

    i love how he showcased the thing before explaining it xD

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

    Would this still work if im at the top of stairs and the npc is at the bottom?

  • @ryujimoshinimation7003
    @ryujimoshinimation7003 12 дней назад

    How can we add an animation on its walking/running and attack mode?

  • @StupidMiners
    @StupidMiners 9 месяцев назад +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?

    • @BiscuitIsUrFriend
      @BiscuitIsUrFriend 6 месяцев назад

      same

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

      if hit.Parent:FindFirstChild(script.Name) then return end -- add this line before doing damage above debounce = true

  • @DaLemonMonke815
    @DaLemonMonke815 8 месяцев назад +2

    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  8 месяцев назад

      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  8 месяцев назад

      It’s quite hard to explain in comments

    • @DaLemonMonke815
      @DaLemonMonke815 8 месяцев назад +2

      Oh wow you actually did respond! That’s fine though I will try my best!

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

      @@DaLemonMonke815 ofc! Good luck with ur game

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

    how would i insert a custom running animation i made so that it will play when he runs

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

      Change the animation in animate script it’s called run

  • @Premium_Me
    @Premium_Me 19 дней назад

    how make modle like this? i got 3d modle from a website and now i wanna chase player and attack it (i don't care aboud animation)
    Becuse my modle doesn't have any humanoid so script not do anything

  • @ch3kerz
    @ch3kerz 7 месяцев назад +21

    my npc isnt moving any advice?

    • @AxelResendez546
      @AxelResendez546 6 месяцев назад +3

      Same

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

      It could be anchored, try unanchoring it

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

      @@Mr_Budders ok

    • @Somedude09LLma
      @Somedude09LLma 6 месяцев назад +3

      Look in the output and click the red it should take you to where the error is and fix it.

    • @brantleychaseB
      @brantleychaseB 5 месяцев назад +7

      name the rig to NPC
      script is
      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

  • @kadsian539
    @kadsian539 9 месяцев назад +2

    what about adding an animation to it with cooldowns

  • @beastmomki
    @beastmomki 7 месяцев назад +1

    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 7 месяцев назад

      if you know tell me

    • @beastmomki
      @beastmomki 7 месяцев назад

      @@gdzh i found out but i can't put the full thing in the comments cuz it doesn't go through

    • @gdzh
      @gdzh 7 месяцев назад

      @@beastmomkiok😢

  • @Igrowtreesforlife
    @Igrowtreesforlife 7 месяцев назад +1

    Someone help me it’s not working and the output says there are no errors

  • @ExtremeShadow
    @ExtremeShadow 10 месяцев назад +2

    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  10 месяцев назад +1

      I think I learned by watching dev kings beginner tutorials

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

    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.

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

    i made my own custom modle but it wont move it only follows my direction

  • @Thechills-y2r
    @Thechills-y2r 21 день назад +4

    It did not work😢

    • @Bizo747
      @Bizo747 3 дня назад +1

      Same😢

  • @jorginhogameplays5algumacoisa
    @jorginhogameplays5algumacoisa 24 дня назад +1

    Could you teach us how we can be one of the enemies?

  • @JumperPlaysRoblox
    @JumperPlaysRoblox 7 месяцев назад +1

    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

  • @greempbruh
    @greempbruh 9 месяцев назад +2

    devmelon thank you and i subscribe you. can you make a video about the hiding system from the enemy?

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

    Its gives me error
    Workspace,rig,ai:30: attempt to compare vector3 < number how i fix it

  • @BushiX5
    @BushiX5 8 месяцев назад +2

    Thanks❤ and how do you replace the animations with different ones?

    • @devmelonroblox
      @devmelonroblox  8 месяцев назад +1

      Yopu check the naimation script and there will be the run id in there youll find it

  • @E_man605
    @E_man605 2 месяца назад

    This is very good cause you dont just give the viewer a free model and say use this you teach the user how to make one themself also how do you make it so a zombie can hit you from a certain distance?

  • @caqblox6843
    @caqblox6843 21 день назад +1

    Why when i died it stop chasing me

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

    It works well unless more than 1 npc is near eachother, then they will kill eachother

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

      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 8 месяцев назад

      @@devmelonrobloxhow to do that?

  • @QwexEdits-m9x
    @QwexEdits-m9x 29 дней назад +1

    How to add animation in There?

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

    So I’m trying to do this but with a pumpkin (basically a model pumpkin) am I able to apply this to my pumpkin as well?

    • @MrDuv2
      @MrDuv2 28 дней назад

      yes

  • @JumperPlaysRoblox
    @JumperPlaysRoblox 7 месяцев назад +1

    devmelon: and it will-.. and it will allow-.. and it will allow you-... and it will allow the NPC to damage you.

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

    idk if you'll respond but is there a way to make it so that the npc stops following you after you get a certain distance away, and starts attacking you when you get close enough?

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

      Something with magnitude and positions

  • @lanzaguisantes-medieval-11
    @lanzaguisantes-medieval-11 6 месяцев назад

    looking good, devmelon but it's better when it has attack animations so the enemy npc would be epic.

  • @Albanian_Guy187
    @Albanian_Guy187 10 дней назад

    How can I make a script that the dummy will respawn and still attack me?

  • @HARBINGER_RBLX
    @HARBINGER_RBLX 4 месяца назад +1

    Thank you So much (very very helpful

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

    I tired this script but its stuck just looking around its not moving or giving me damage

  • @Marmello11
    @Marmello11 14 дней назад +2

    when i kill the npc it still follows me around.. the following part is the humanoidrootpart...

  • @anhvietsub-q9n
    @anhvietsub-q9n 21 день назад

    it solved my problem thanks so much

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

    im just wondering how you can give them a punching animation?

  • @confleds277
    @confleds277 Месяц назад

    This works perfectly fine on the client but as soon as more than one player is on the server it doesnt follow one of them. How can I fix that?

  • @apriceer9148
    @apriceer9148 25 дней назад

    what am i copy and pasting for the animate?

  • @PrusaksG
    @PrusaksG Месяц назад

    How can i make it spawn randomly around my map and multiple of them

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

    Is it possible to make the chasing NPC follow you in a way while flying? The way it falls off into the void is not what i want.

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

    Hey, I made multiple enemies, and they keep killing each other. Is there a way to fix this?

  • @DODOFAM-join
    @DODOFAM-join 5 месяцев назад +1

    TYSM the other yt gave me fake scripts tysm!!! def earned a sub

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

    It follows me, but doesn't kill is there a way to fix that I copied and pasted it from Bluewithafruit but it works and everything just not the kill part but I need it for my game lol

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

    NPC doesn't damage you when you stand on top of it and also how do I adjust it's speed?

  • @dylanwickremasurendra9930
    @dylanwickremasurendra9930 6 дней назад

    How can you make is chase you from a limited amount of range because now it chases you from across the map

    • @johanortega4223
      @johanortega4223 4 дня назад +1

      ask chat gpt, im learning from Him to scripting he knows a lot

  • @Gamepro-d6c
    @Gamepro-d6c 4 месяца назад +1

    But how Do I stop enemies from killing each Other? New Sub

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

    Can someone send a link to the script through pastebin? for some reason it isn't working for me and i think it is because of the position of the end but i tried to fix that to make everything align exactly how the video's script sentences are positioned and it still doesn't work

  • @bananakid8270
    @bananakid8270 10 месяцев назад +1

    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 6 месяцев назад

      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

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

    Yo Devmelon, How to make a pathfinding npc that attacks you?

  • @stumbix
    @stumbix 4 месяца назад +1

    How do we add animations to the npc?

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

      Using the animate script you change the animations

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

    can anyone help i did it but my rig is just floating and doing the fall animation

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

    How do u make it so he only attacks when u get close to him?

  • @kibainuzuka9485
    @kibainuzuka9485 Месяц назад

    how do i make it then when the player approaches the npc he starts following him

    • @Korby69
      @Korby69 Месяц назад

      Change math.huge to wtv range you want

  • @familywhitworth3559
    @familywhitworth3559 2 месяца назад +2

    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

  • @farooqdarwish1
    @farooqdarwish1 Месяц назад +1

    BRO THANK YOUUUU

  • @daveiscool24
    @daveiscool24 7 месяцев назад +1

    It worked the first time but when I colored it it stopped working

    • @devmelonroblox
      @devmelonroblox  7 месяцев назад

      Make sure you spelled everything correctly

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

    how the hell do u kill the npc? for the life of me i can't get it to die, it just keeps following me after death

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

    Is there any way to add a range of agro for the rig so it does t attack me from anywhere?

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

      change the math.huge on the MaxDistance into any number you want, that works for me

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

    What if you don't want it to chase you but attack upon entering the radius?

  • @Not_Th3ron
    @Not_Th3ron 22 часа назад

    After I kill it no matter how far away I run it still can deal damage to me

  • @asremier3759
    @asremier3759 2 месяца назад

    Is there a way to make an area inaccessible for it? To prevent it getting stuck I mean.

  • @un24identified
    @un24identified Месяц назад

    how do u make it so when u get touched by it u get kicked instead

  • @BiscuitIsUrFriend
    @BiscuitIsUrFriend 6 месяцев назад

    yo dev melon how do i make the rig not hurt any other rigs i might put on there?

  • @s1o4x7
    @s1o4x7 Месяц назад

    Bro why dont you try this idea, it will make it lot easier for us to do:
    Just copy paste your coding in the description its really helpful ngl...

  • @MasterNoobwayOfficial
    @MasterNoobwayOfficial 2 месяца назад

    It is not making an animation for me, can you help me with this?

  • @SafeOfArsenal
    @SafeOfArsenal 6 месяцев назад

    is it possible to make a safe zone where the npc wont go inside of?

  • @Seenanimatedddti
    @Seenanimatedddti 6 месяцев назад

    It's good, but if spawn too much they can kill each other, can you make them cannot kill each other?

  • @deathreaper4200
    @deathreaper4200 10 месяцев назад +1

    thank you so much

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

    0:25 IT ACTUALLY OOF MY BRAIN

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

    can you make one where a mesh model can attack cause I can't find one of those videos

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

    Can I use a R6 dummy for this?