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
This was exactly what I meant and you really impressed me with this bro, best tutorial I’ve ever watched
best tutorial ive ever seen, straight to the point just overall amazing you earned a sub
You're a hero, this gun is like the OG Guns in Roblox World War games, so much nostalgia
@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.
Real good tutorial. Can't wait for the second part!
this is the best gun tutorial i've ever seen, good job!
Wow dude I'm so happy that u returned! BTW can't wait until part 2!
Bro this is amazing, greats tutorials fr. Keep going like this!
Wtf this editing is so good, the gun works well also
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
Definitely excited for p2, i need that ammo counter LOL
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!
Our True Legend Came Back
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
Жыл бұрын
The game is dead but base raiders 2 is rumored.
best thing I ever seen
Nice you are back
Great tutorial and if you can, can you do a tutorial on how to make other guns like a shotgun?
Bro just appeared.
@anyalabunski
Жыл бұрын
True
Muzzle flash and animations would be cool.
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
Жыл бұрын
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
Жыл бұрын
@@epic4 Thank you so much man, can’t wait to see part 2
You should also add some animations to the weapon, so it donesn't look sluggish, eitherway, great gun kit
@epic4
Жыл бұрын
i tried animations i think that deserves a video on its own due to how complex it is
Quick question, is it the while loop that updates the position of the bullet which makes it move?
@epic4
Жыл бұрын
Yes
you should use contextactionservice instead because you can implement mobile buttons easily into the game and optimize guns for consoles
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?
how to reduce the bullet delay cause when i move and shoot the bullets arent accurately firing from the gun
what's your opinion on Realish 2 development
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.
How do you make the gun point where you're cursor is?
not all heroes wear cape.
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
Жыл бұрын
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
Жыл бұрын
@@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
Жыл бұрын
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
Жыл бұрын
@@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.
why do we put bullet render script in gui?
Can you make the gun work in Mobile bcz when I tried it at mobile it wont work?
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
Жыл бұрын
Nvm i found that you did add spread to the very first tutorial!
will you be able to show us how to zoom in/aim with the gun?
@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
pt2: add spread, animation compatibility (like when you shoot and reload) , and ammo system!!!!
@CodeInWhite
12 күн бұрын
Pretty sure she or he is down scripting
@CodeInWhite
12 күн бұрын
Part 2 never came lol
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
Жыл бұрын
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
Жыл бұрын
@@epic4 ah i didnt notice that because usually thats enough for most people including me
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
Жыл бұрын
i plan to do that eventually as part of part 2
@ZagoraZz
Жыл бұрын
@@epic4 thank you youre the best
could u make it so u can reload it and make it have anims?
When is part 2 gonna come out? please make a discord for communication!!
@uniguy4647
7 ай бұрын
I think never
cool, i still have no idea how it works :D
@epic4
Жыл бұрын
no worries if you dont understand just follow what it says to do especially the highlighted text
You should make a sword
I have some strange problem, sometime my ray goes from my gun to 0,0,0.
How do I make it reload?
add ammo?
How to make bullet's direction to center of camera
3:09 My checkpoint :)
why does the gun still shoots when it's unequipped i can't find the error
it works but it fires its bullets under my character
Got a error Workspace.Tool.Script:5: attempt to call a nil value
RemoteEvent is not a valid member of Tool? how do i fix this
@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
How to add mobile support???
@UBZNGaming
26 күн бұрын
Yeah
Yo when are we getting part 2 :(
@uniguy4647
2 ай бұрын
I think never(
@DanielLikesEggs
Ай бұрын
@@uniguy4647 yeah, never
:0👍
@TheAxelDc
Жыл бұрын
THX for the heart :>
How to make a shotgun using this?
how to add a reload
Personally i did everything and it didnt work.. can anyone help me please.
lol
the bullet is spawning any where near the handle
how would you make it reload?
@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
Жыл бұрын
@@epic4 thanks but I have figured a way to do it on my own
@scarcehdx1746
Жыл бұрын
@@deleteduser34327 how
@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
I tried everything AND IT DOES NOT WORK please help
@spriteman1925
11 ай бұрын
Go in description and copy the script then
3:39
@katanareal149
Жыл бұрын
?
I guees u girl ._.
are you a girl or a boy?
when is that part 2 coming???