How to Code a gun in Roblox Studio! (5th remake)

Ойындар

In this tutorial, you learn to code a gun in Roblox Studio, to a quality like the best games!
Starting from scratch, all the way to the model plus some extra features.
When reading the code, the code is highlighted so you can easily keep track and finish it within a few hours!
The code in text, part 1:
docs.google.com/document/d/e/...
Part 2:
docs.google.com/document/d/e/...
The model, part 1:
www.roblox.com/library/107791...
Part 2:
www.roblox.com/library/997244...
Timestamps:
Part 1 0:00
Part 2 6:03

Пікірлер: 96

  • @nebollous
    @nebollous Жыл бұрын

    This was exactly what I meant and you really impressed me with this bro, best tutorial I’ve ever watched

  • @ZagoraZz
    @ZagoraZz Жыл бұрын

    best tutorial ive ever seen, straight to the point just overall amazing you earned a sub

  • @4f52
    @4f52 Жыл бұрын

    You're a hero, this gun is like the OG Guns in Roblox World War games, so much nostalgia

  • @4f52

    @4f52

    Жыл бұрын

    Also, not to mention this tutorial is extremely well made, explaining even the most basic concepts in a manner which anyone (no matter their experience with coding) can understand.

  • @reach8780
    @reach8780 Жыл бұрын

    Real good tutorial. Can't wait for the second part!

  • @freddospaghettio3157
    @freddospaghettio3157 Жыл бұрын

    this is the best gun tutorial i've ever seen, good job!

  • @maciezez
    @maciezez Жыл бұрын

    Wow dude I'm so happy that u returned! BTW can't wait until part 2!

  • @Ema1441_
    @Ema1441_ Жыл бұрын

    Bro this is amazing, greats tutorials fr. Keep going like this!

  • @liamjamesmarcelino6205
    @liamjamesmarcelino6205 Жыл бұрын

    Wtf this editing is so good, the gun works well also

  • @kokobroxd
    @kokobroxd Жыл бұрын

    instead of using userinputservice you could use contextactionservice, this way you can also implement mobile buttons easily into your game, and binding actions when equipped and unbinding actions when unequipped makes your script look alot simpler

  • @scarcehdx1746
    @scarcehdx1746 Жыл бұрын

    Definitely excited for p2, i need that ammo counter LOL

  • @ArchiezzWorld
    @ArchiezzWorld Жыл бұрын

    Bro, can you add reloading to it, and scope + animations? It would be VERY cool if it had those. Also, i LOVEE your content! Keep making more!

  • @blackpunkcz1157
    @blackpunkcz1157 Жыл бұрын

    Our True Legend Came Back

  • @jerronng5568
    @jerronng5568 Жыл бұрын

    I remember you Love your base raiders videos back then Wish you could revisit the game for a bit But anyways nice job with what ur doing now

  • @DeadAccount53885

    @DeadAccount53885

    Жыл бұрын

    The game is dead but base raiders 2 is rumored.

  • @meditegrub5811
    @meditegrub5811 Жыл бұрын

    best thing I ever seen

  • @ftblaze6175
    @ftblaze6175 Жыл бұрын

    Nice you are back

  • @voloMan092
    @voloMan092 Жыл бұрын

    Great tutorial and if you can, can you do a tutorial on how to make other guns like a shotgun?

  • @Dev_Gear
    @Dev_Gear Жыл бұрын

    Bro just appeared.

  • @anyalabunski

    @anyalabunski

    Жыл бұрын

    True

  • @Kinzl
    @Kinzl Жыл бұрын

    Muzzle flash and animations would be cool.

  • @cal7757
    @cal7757 Жыл бұрын

    Bro when’s the second part out I’d love how to learn to do an ammo counter, also a question, how would you do a semi auto firing mode? For weapons such as Rifles, pistols and Snipers

  • @epic4

    @epic4

    Жыл бұрын

    for semi auto i just remove the "loop" in the local script that would keep the gun firing if you held the mouse down

  • @cal7757

    @cal7757

    Жыл бұрын

    @@epic4 Thank you so much man, can’t wait to see part 2

  • @nikifn
    @nikifn Жыл бұрын

    You should also add some animations to the weapon, so it donesn't look sluggish, eitherway, great gun kit

  • @epic4

    @epic4

    Жыл бұрын

    i tried animations i think that deserves a video on its own due to how complex it is

  • @nebollous
    @nebollous Жыл бұрын

    Quick question, is it the while loop that updates the position of the bullet which makes it move?

  • @epic4

    @epic4

    Жыл бұрын

    Yes

  • @araphis836
    @araphis836 Жыл бұрын

    you should use contextactionservice instead because you can implement mobile buttons easily into the game and optimize guns for consoles

  • @mitersaw15
    @mitersaw15 Жыл бұрын

    i have an error that says that replicated bullets is not a valid member of replicated storage and its from the first line in the bullet render script. What do i do?

  • @normalerror7611
    @normalerror7611 Жыл бұрын

    how to reduce the bullet delay cause when i move and shoot the bullets arent accurately firing from the gun

  • @davimarinho7803
    @davimarinho7803 Жыл бұрын

    what's your opinion on Realish 2 development

  • @smlclips9758
    @smlclips97586 ай бұрын

    I have an issue where i shoot the gun and it does the noise and damages the dummys, but the bullets only render half the time, and dont travel far before dissapearing.

  • @tithritheapak3900
    @tithritheapak3900 Жыл бұрын

    How do you make the gun point where you're cursor is?

  • @memenadekhanh3992
    @memenadekhanh3992 Жыл бұрын

    not all heroes wear cape.

  • @scp_1012
    @scp_1012 Жыл бұрын

    Loved your tutorial. One issue I have with the gun though is that I notice a ray offset/delay every time it fires. Like if you are moving around and you fire the gun, the ray won't be casted from the barrel, but rather from your arm, or in the worst cases even your back. Is there any way to fix this so that it always fires from the barrel when moving around?

  • @epic4

    @epic4

    Жыл бұрын

    This is intentional because of the actual delay between your input and the server. As a result this is actually the most accurate way to show where the bullet is relative to other players positions meaning you can hit them reliably without thinking your bullet goes through your target unharmed

  • @scp_1012

    @scp_1012

    Жыл бұрын

    @@epic4 Oh awesome that's good to know, thank you! Just curious though, is there something you can do to the client to make it look like it's always shooting from the barrel, even when moving? I notice some games have it so from the player's perspective, their own gun is always shooting from the front of the barrel even when moving. This is on-top of it being normal for other players as well. Thank you again for responding though!

  • @epic4

    @epic4

    Жыл бұрын

    I know a game that attempted to ray trace from the barrel on the client first to make it look like you are shooting instantly from the barrel, but it sacrifices accuracy at that first frame, and is unnecessarily complex to duplicate, since you have to make a new communication between the server and client. Also, the effect you see from other players having their bullet start from the barrel is actually what you see when the server tells your client to replicates the visuals for you. The bullet visual I showed how to make does the same thing, with the server telling the client to create the tracer. Tldr you can but it is not worth the effort. I place accuracy over aesthetics.

  • @scp_1012

    @scp_1012

    Жыл бұрын

    @@epic4 Awesome. That's helpful to know for the future thank you! I just have one more question really. I've been looking around and I've noticed that there are two types of categories that people put guns under: Hitscan & Raycast. Would this gun be raycast? Can a gun only be raycast or only be hitscan? And what would the difference be between a hitscan gun and a gun like the one you created in the video? Thank you for answering my questions btw I really do appreciate it.

  • @newvortexmind2738
    @newvortexmind27386 ай бұрын

    why do we put bullet render script in gui?

  • @UBZNGaming
    @UBZNGamingАй бұрын

    Can you make the gun work in Mobile bcz when I tried it at mobile it wont work?

  • @el_archi_mago
    @el_archi_mago Жыл бұрын

    Could you tell me rq how to make the bullets spread? I know how to code, but directions and raycasts are more than me, what should i touch up to add it?

  • @el_archi_mago

    @el_archi_mago

    Жыл бұрын

    Nvm i found that you did add spread to the very first tutorial!

  • @epiclyspacenoob5689
    @epiclyspacenoob5689 Жыл бұрын

    will you be able to show us how to zoom in/aim with the gun?

  • @epic4

    @epic4

    Жыл бұрын

    Yeah I plan to do that in part 2 for the zoom while the aim will be for part 3 as aiming is an animation

  • @scarcehdx1746
    @scarcehdx1746 Жыл бұрын

    pt2: add spread, animation compatibility (like when you shoot and reload) , and ammo system!!!!

  • @CodeInWhite

    @CodeInWhite

    12 күн бұрын

    Pretty sure she or he is down scripting

  • @CodeInWhite

    @CodeInWhite

    12 күн бұрын

    Part 2 never came lol

  • @upwhats5823
    @upwhats5823 Жыл бұрын

    This tutorial is very useful for beginners and good for people who dont care about security, but for a security freak like me, sending pure mouse cursor data with basically no security on the remote event? You are basically asking for trouble, a hacker could spam the remote event thousands of time and potentially crash the server (because of the sheer amount of ray cast and bullets), thats the worst case. The best case is some script kiddies firing 200 bullets per seconds with aimbot and killing everyone in sight.

  • @epic4

    @epic4

    Жыл бұрын

    At the automatic fire part of the vid I solved this problem so not everyone might have been able to reach the end unless they either follow through or skip parts of the vid

  • @upwhats5823

    @upwhats5823

    Жыл бұрын

    @@epic4 ah i didnt notice that because usually thats enough for most people including me

  • @ZagoraZz
    @ZagoraZz Жыл бұрын

    i dont know if this is too much but can you show how you would be able to make it shoot like a shotgun?

  • @epic4

    @epic4

    Жыл бұрын

    i plan to do that eventually as part of part 2

  • @ZagoraZz

    @ZagoraZz

    Жыл бұрын

    @@epic4 thank you youre the best

  • @j4x4x
    @j4x4x Жыл бұрын

    could u make it so u can reload it and make it have anims?

  • @genocidal439
    @genocidal439 Жыл бұрын

    When is part 2 gonna come out? please make a discord for communication!!

  • @uniguy4647

    @uniguy4647

    7 ай бұрын

    I think never

  • @leafy4098
    @leafy4098 Жыл бұрын

    cool, i still have no idea how it works :D

  • @epic4

    @epic4

    Жыл бұрын

    no worries if you dont understand just follow what it says to do especially the highlighted text

  • @anx2065
    @anx2065 Жыл бұрын

    You should make a sword

  • @cbuccbuc
    @cbuccbuc Жыл бұрын

    I have some strange problem, sometime my ray goes from my gun to 0,0,0.

  • @carrylbenlibron1891
    @carrylbenlibron189118 күн бұрын

    How do I make it reload?

  • @ddeathlmao
    @ddeathlmao10 ай бұрын

    add ammo?

  • @Miyaohehe
    @Miyaohehe Жыл бұрын

    How to make bullet's direction to center of camera

  • @ferjkndsfkindcebkjwdbjodew5265
    @ferjkndsfkindcebkjwdbjodew5265 Жыл бұрын

    3:09 My checkpoint :)

  • @imjust_someguy
    @imjust_someguy Жыл бұрын

    why does the gun still shoots when it's unequipped i can't find the error

  • @UrbanWarrior.
    @UrbanWarrior. Жыл бұрын

    it works but it fires its bullets under my character

  • @_Berserker_777
    @_Berserker_777 Жыл бұрын

    Got a error Workspace.Tool.Script:5: attempt to call a nil value

  • @fallencode3454
    @fallencode3454 Жыл бұрын

    RemoteEvent is not a valid member of Tool? how do i fix this

  • @epic4

    @epic4

    Жыл бұрын

    I make sure to have a waitforchild for the remote event since the scripts sometimes load faster than the remote event can be added

  • @joshuadavid3975
    @joshuadavid39753 ай бұрын

    How to add mobile support???

  • @UBZNGaming

    @UBZNGaming

    26 күн бұрын

    Yeah

  • @user-nc3vf9il9f
    @user-nc3vf9il9f5 ай бұрын

    Yo when are we getting part 2 :(

  • @uniguy4647

    @uniguy4647

    2 ай бұрын

    I think never(

  • @DanielLikesEggs

    @DanielLikesEggs

    Ай бұрын

    @@uniguy4647 yeah, never

  • @TheAxelDc
    @TheAxelDc Жыл бұрын

    :0👍

  • @TheAxelDc

    @TheAxelDc

    Жыл бұрын

    THX for the heart :>

  • @Miyaohehe
    @Miyaohehe Жыл бұрын

    How to make a shotgun using this?

  • @LuisCarlos-tg3zq
    @LuisCarlos-tg3zq Жыл бұрын

    how to add a reload

  • @luvvddy
    @luvvddy11 ай бұрын

    Personally i did everything and it didnt work.. can anyone help me please.

  • @dogebread5263
    @dogebread5263 Жыл бұрын

    lol

  • @ServerServer-vb4oj
    @ServerServer-vb4oj Жыл бұрын

    the bullet is spawning any where near the handle

  • @deleteduser34327
    @deleteduser34327 Жыл бұрын

    how would you make it reload?

  • @epic4

    @epic4

    Жыл бұрын

    I'll do it in a part 2 but I'll give a quick description When you press a button you have your gun not be able to shoot for some amount of time then your ammo will be refilled and your gun is ready to shoot again

  • @deleteduser34327

    @deleteduser34327

    Жыл бұрын

    @@epic4 thanks but I have figured a way to do it on my own

  • @scarcehdx1746

    @scarcehdx1746

    Жыл бұрын

    @@deleteduser34327 how

  • @deleteduser34327

    @deleteduser34327

    Жыл бұрын

    @@scarcehdx1746 add a value and make it go down with every click , then when it hits 0 make it reload / go back to the original number

  • @Robuster13
    @Robuster1311 ай бұрын

    I tried everything AND IT DOES NOT WORK please help

  • @spriteman1925

    @spriteman1925

    11 ай бұрын

    Go in description and copy the script then

  • @smite_ro7166
    @smite_ro7166 Жыл бұрын

    3:39

  • @katanareal149

    @katanareal149

    Жыл бұрын

    ?

  • @Whitesquishy637
    @Whitesquishy637 Жыл бұрын

    I guees u girl ._.

  • @AverageFries
    @AverageFries Жыл бұрын

    are you a girl or a boy?

  • @ZagoraZz
    @ZagoraZz Жыл бұрын

    when is that part 2 coming???

Келесі