How to Make a Knockback Attack Script | Roblox Studio Tutorial

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 136

  • @MajesticUC
    @MajesticUC  Рік тому +5

    Like and Sub! Tell me what tutorial I should make next!!!

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

      Particle effects

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

      Make Stun PLEASE! I NEED IT!!!!

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

      question, how can I make the knock back on the 5th hit

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

      The knockback is the final parameter of the remote event. Just add 2 more else ifs and then increase the knock back on the final punch

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

      Hey can u help it won't work no errors in output or nothing I don't what's happened I have check and it's the same do u know how I could fix I have tried everything??

  • @chessbrahh2068
    @chessbrahh2068 8 місяців тому +3

    this worked very well for me. i already had my own damage code, so i simply pasted the knockback() function into my scripts and made sure i was calling it correctly. thank you!

    • @MasimbaMvura-y1n
      @MasimbaMvura-y1n 8 місяців тому +2

      Yo rlly quick can you tell me which bit you pasted

    • @chessbrahh2068
      @chessbrahh2068 8 місяців тому

      @@MasimbaMvura-y1n
      sure - just call this function whenever an enemy gets hit. it's all you need. (make will need to tweak 2 of the lines, so that they refer to whatever your enemy and player variables are named)
      --this knocks the ENEMY back, not a player
      function knockback()

      --local power = math.random(0,75)
      local power = math.random(0,50)

      --this should refer to the enemy humanoid root part (you might need to tweak this line)
      local ehrp = model.HumanoidRootPart

      --this should refer to the player who hit the enemy (you might need to tweak this line)
      local plyr = game.Players[configs.creator.Value]

      --print("the player who hit me was " .. plyr.Name)

      local uhrp = plyr.Character.HumanoidRootPart
      local att = Instance.new("Attachment", ehrp)
      local lv = Instance.new("LinearVelocity", att)
      lv.MaxForce = 9999999
      lv.Attachment0 = att
      local lookVector = uhrp.CFrame.LookVector
      lv.VectorVelocity = lookVector * power
      local tween = ts:Create(lv, kbtween, {VectorVelocity = lookVector * 0.1})
      tween:Play()
      game.Debris:AddItem(att, 0.3)
      end

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

    Your tutorials are pretty useful , thank you ! Keep going

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

    Just a note, client hitboxes can be easily expoilted a good tip is to add checks if you are doing client hitboxes or just do server hitboxes.

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

      Thank u so much!

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

      @@zenikui so you see how in that script mostly from this it sends 'size' exploiters can just do this game.ReplicatedStorage.Events.Hitbox:FireServer(vector3.new(2048,2048,2048),vector3.new(3),math.huge(),999) client should not have the power to set hitbox size or the damage, things like that should be handled on server as well as having hitbox summon on server yeah you might get delays in the hit but it's more secure. most checks i would say for this code would be checks to see if size is too big and if the player is in range of the person casting the hitbox like using like a magintue of how far in front of player's character the hitbox should activate damage/knockback as well as a check for damage so expoilters can't just do inf damage. No offense to the creator at all just wanting to be well helpful

  • @RipXy3rx
    @RipXy3rx 6 місяців тому +1

    To add damage you need to go to hitbox script, go to line 33 and add another line and type in the new line "local damage = Your damage

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

    Thanks, your videos are really helpfull, i belive you will have sucess if you keep doing this :D (sorry if im using bad grammar, im from brasil lol)

  • @mongobongo6654
    @mongobongo6654 7 місяців тому +1

    hello :D i rly like your videos about coding. many other devs just skipping entire code to make video not very long. tysm for that! but the thing is when at 2:10 you were making knockback, on video it was sliding to position where it stops going , but for me i just almost tp there (it not tp at all, it going there very fast it looks like it tp) pls say what it can be im confused :( ty :)

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

      bro i have the same problem, but i think try making the power low but the debris duration longer?

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

    I think you are my new favorite roblox dev youtuber!

  • @user-om5wq4nv3x
    @user-om5wq4nv3x Рік тому +2

    You shouldn’t be using .Touched, instead use overlap perams or get parts in part.

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

    thank you man
    u earned a sub and a like :)

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

    Hey Dev can u help I have done everything right double check but I dosent work I have checked in output nothing wrong check in vid and it's the exact same do u know what's happening if so can u help?

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

    how would i add a animation to knowckback and also how do i add sounds to the punches

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

    Can u do one on stunning or air combos pls keep it up btw

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

      Yeah Definitely!

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

      ​@@MajesticUC tysm ❤

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

      @@MajesticUCStun would be great (air combos to)

  • @ragnability4232
    @ragnability4232 7 місяців тому +2

    I tried this, though the knockback is jittering and laggy for some reason..

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

      That jittery thing will not happen in an actual game. Im assuming you’re testing on a dummy. The jitter is when the dummy moves out of your network ownership so it shouldnt happen in an actual game

  • @1nsanity_
    @1nsanity_ Рік тому

    This is such a great tutorial! And can you do a particle tutorial

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

    this is good for me cuz i cant really code but can animate really well

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

    hey can you make an animation for the 3 part and do it so that you get cash
    when it dies and so it will respawn

  • @Diamondplayz-hu9he
    @Diamondplayz-hu9he Рік тому

    Could make a tutorial on how to add a animation when the dummy is hit. Also keep your vids going, there great!

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

    Could you please do tutorial how to apply Stun after last punch in combo and how to add stun animation?

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

    hey can u make a video about the hit stun and the stun u will recieve when m1 or the one who get m1ed?

  • @GlitchedHunter16
    @GlitchedHunter16 5 місяців тому

    You should make a tutorial on how to add stun to the punches

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

    my knockback is laggy it kinda just teleports the player it hits

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

    Hey could you possibly tell how to make sfx with it or include sounds when they get hit, or animation when they got hit?

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

    next devlog when

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

      I've been away for a few days now but I'm finally back! Should come out either this week or next week 🤷

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

      @@MajesticUC yay

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

    I have followed the Tutorial to the Tea and I have even copied from the pastebins and yet the knockback seems to be laggy, almost like the tween isn't working

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

    i made it so i have 5 punches but it says if kb

  • @wasdwar4egregsgsfdgrsdfgsreg

    can you make another part that shows how to add vfx and make separate attacks

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

    hey just wondering if you could make a stun tutorial thank you.

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

    PLS MAKE STUN TUTORIAL!!!!

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

    can u make a tutorial showing us how to use particles and SFX?

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

    whats that opening sound effect :o

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

    This works way too well
    Here are some ideas:
    • The person who takes damage is animated and has stun
    • Ability with toolbar GUI that displays cooldown(I didn’t understand it during the dev log you made)

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

      For the first step, you can simply add an animation by accessing the hit.Humanoid.Animator within the damage script, and then load the animation onto the character. For the stun effect, use a separate script (which should be disabled by default) within the main script. In the damage section of the main script, create a function in the 'stunhandler' script that disconnects the player's keyboard input from the game, allowing them only to control the camera. After a certain duration, this 'stunhandler' script should be removed. To achieve this, you can make the 'stunhandler' script clone itself onto the hit.Character or a similar target.
      Sorry if you couldn't understand me, my english is bad, im trying to learn.

  • @1VRRR
    @1VRRR Рік тому +3

    When new dev LOGG?????????????

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

      I have been away for a while. It should come out by next week or the week after!

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

    i can learn from this, thanks a lot 👍

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

    Everything works fine for me but it looks a bit laggy for some reason, I tested it in game (not in studio) to check if it was a studio issue but it wasnt. The only difference between mine and yours is that the script is stored on the server. It also can't be my pc lagging cuz it doesnt have issues on other games at all, roblox included.
    If you or anyone could help me out I would really appreciate it.
    edit: (just realized yours is also stored on the server)

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

      Well it rlly depends on how you’ve made the knockback. In the game im making rn, I use body velocity which isnt what i used in this video. Perhaps try using bodyvelocity or linear velocity instead for your knockback

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

      @@MajesticUC I did the exact same knockback as you (linear velocity), using pretty much the same code
      edit: I figured out what was making it laggy, line that rotates the enemy towards the attacking player. But do you know how to get that effect in another way?
      function KnockBack(pHrp, eHrp, power)
      local att = Instance.new("Attachment", eHrp)
      local lv = Instance.new("LinearVelocity", att)

      lv.MaxForce = 999999
      lv.Attachment0 = att
      lv.VectorVelocity = pHrp.CFrame.LookVector * power
      / / / Thats the rotation thing \ \ \
      eHrp.CFrame = (pHrp.CFrame - pHrp.CFrame.Position + eHrp.CFrame.Position) * CFrame.Angles(0, math.rad(180), 0)

      game.Debris:AddItem(att, 0.2)
      end

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

      Idk if I can help then. Mine isnt laggy at all. Sorry I cant help 😢

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

      @@MajesticUC With my latest changes it seems like when a second player joins in is when the knockback is laggy.
      Could you try to launch a local server with 2 players to see if the knockback becomes laggy, if you could it would be very very appreciated! 🙏

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

    how can i make the player ragdoll when he gets knockback?

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

    How to put animation for the victim?

  • @MajorLightning
    @MajorLightning 8 місяців тому

    Wait can you add this to a ragdoll script? If you can, then how?

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

    hey man can u make downslam and uppercut?

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

    Very cool thanks! anything i could add to make them fling up a bit?

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

      Yes you could. You could fire the knockback parameter as a vector 2 in the local script. Then in the server script inside of the knockback function you can do lv.VectorVelocity = uhrp.Cframe.LookVector * power.X + Vector3.new(0, power.Y, 0)

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

      @@MajesticUC where do I start it? At local lookvector or lv.Vector velocity?

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

      @@Hehelol3321 start what?

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

      @@MajesticUC at waht point do I write it?

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

      @@Hehelol3321 write what

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

    Can you make knockback physics

  • @AFloppyStick
    @AFloppyStick 6 місяців тому

    hey can you fix this uhh error " ServerScriptService.Script:58: attempt to compare nil

  • @sadeceturkiye.
    @sadeceturkiye. Рік тому +1

    Please do q to dash

  • @TiagoAmbrósiozg
    @TiagoAmbrósiozg Рік тому

    you can make plz part 3 it giving sounds

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

    how do i change the damage of the punch?

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

      in the hitbox function there is a parameter for damage. Just change that

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

      heyyy its not working :(@@MajesticUC

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

    is it possible to make them ragdoll after they get hit

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

    how do I make it do knockback every hit? EDIT: nvm i found out how to do it

  • @AlanJohn-r2h
    @AlanJohn-r2h Рік тому +1

    0:24 how can an ai voice have voicecrack !?!?!

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

    Is it possible to change the direction of knockback like upwards?

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

      Yes

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

      yea i figured it out lol but amzing response very helpful 9/10 @@Stickdraws

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

      @@fkn_ant lol I didn’t know how tho sorry

  • @Bakalll9_1
    @Bakalll9_1 5 місяців тому

    Uhh mine doesnt do knock back

  • @엘에스쥐
    @엘에스쥐 5 місяців тому

    How to ragdoll?

  • @epicmancool-r2m
    @epicmancool-r2m Рік тому

    pls show how to add ragdoll to it

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

    can you make a fireball for r6?

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

    Good Work!! frfr

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

    can you make a damage blocking guide?

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

    How to add sound on punch?

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

      I think that after one of the hits in the non velocity script add a sound and then after the attack play the sound.

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

    Its not working :(

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

    You earned a sub

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

    Please make a stun tut!

    • @FlamezStudioYT
      @FlamezStudioYT Місяць тому +1

      Stunning is as easy as disabling player movement (by setting the humanoids move speed to nothing) and having some sort of condition, something like a “status” that changes to stunned, and when it’s set to stunned you aren’t able to M1 or do any skills or etc.

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

    tysm it worked

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

    i wanted to start with sorry but aswell as sorry if its ok even the what i said was horrible to you i was wondering if you could mabye help work on a project with me if not you can so no and say something as rude as i did last time just cause it didnt work for me☹️

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

      is that a yes or no

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

    can u do kicking next

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

      i think that for kicking you can just change the animation for a kicking animation

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

      @@LostLoserHero yup

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

      @@LostLoserHero nope and the hit box aswll as how it would effect you when u were hit🤨

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

    THNXX

  • @Takigue5425
    @Takigue5425 3 місяці тому