How to code a Gun in Roblox Studio! part 1

Ойындар

Coding a gun in Roblox studio may seem too much work, or be too complex to understand. With this tutorial, you will be able to create a good fighting game as a result!
Chapters, along with the completed models as a result of following the steps:
00:00 - First part - coding the gun
www.roblox.com/catalog/908506...
04:17 - Second part - Gun features
www.roblox.com/catalog/909651...

Пікірлер: 100

  • @AustinAndGamerz
    @AustinAndGamerz2 жыл бұрын

    the legend is back, glad you are still active!

  • @KLEY_
    @KLEY_2 жыл бұрын

    really good work i love guns like this ty for help

  • @Marioman73
    @Marioman732 жыл бұрын

    You have learned

  • @blackpunkcze74
    @blackpunkcze742 жыл бұрын

    YOOO THE LEGEND IS BACK LES GO!!!

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

    For part 2, i recommend making it to where you can disable full auto in the script, make it to where you can apply animations for reloads, pullouts, and recoil, and an ammo system (which was already promised)

  • @giga9001
    @giga90012 жыл бұрын

    Underrated channel

  • @iX_JJPRO
    @iX_JJPRO2 жыл бұрын

    This is gonna be lit

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

    Please part 2 soon as possible which there's a reload system, sound effect on the bullet, and a "E" feature where the gun (down) is carried by the hand. I would support this channel i already subscribed!

  • @JoSeph-qo4gq
    @JoSeph-qo4gq2 жыл бұрын

    Wow, unlike all the other scripting tutorials, this one is kind of short But the text is hard to read by the time they disappear Your tutorials will help a developer make a very successful game one day 👍

  • @epic4

    @epic4

    2 жыл бұрын

    i tried to make the text like its "seamless talking" so its like a constant flow of information without being bored

  • @JoSeph-qo4gq

    @JoSeph-qo4gq

    2 жыл бұрын

    @@epic4 Well it kind of worked but it has room for improvment

  • @noxusnobos6541

    @noxusnobos6541

    2 жыл бұрын

    @@epic4 hey when you put a server script in the tool hackers can access it though

  • @KLEY_

    @KLEY_

    2 жыл бұрын

    @@noxusnobos6541 no because server script is working on server not local

  • @noxusnobos6541

    @noxusnobos6541

    2 жыл бұрын

    @@KLEY_ k

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

    Could you explain the code too? it's rather hard to learn if I'm just copying the code without knowing why it was written that way and not a different way

  • @supremekevin3359
    @supremekevin33592 жыл бұрын

    I miss ur base raiders vid cuz I love ur design I rate it 1000000/10 I hope u back play base raiders man

  • @OVERSEERYT10000K
    @OVERSEERYT10000K2 жыл бұрын

    hey dude on your noob vs zombie vid how do you get the guy with 4 lives i forgot the hero name but how do you get him

  • @oluwasegunfunmi9018
    @oluwasegunfunmi90182 жыл бұрын

    this is the best

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

    nice

  • @interactivesage4609
    @interactivesage46092 жыл бұрын

    Quick question, will you make more noobs v zombies content?

  • @epic4

    @epic4

    2 жыл бұрын

    Probably but I need video ideas

  • @memenadekhanh3992
    @memenadekhanh39922 жыл бұрын

    Please make part 2. I liked your video and sub your channel.

  • @susansantos7350
    @susansantos73502 жыл бұрын

    How we can make it so when we hold it's shoot only once like not multiple times. (I hope you got my idea). For example: I want to make a Pistol so I need only 1 bullet per hold. I hope that you will reply and you will make a video for that, please.

  • @epic4

    @epic4

    2 жыл бұрын

    I just remove the loop that causes auto fire in the local script If you want to keep the loop then you can just break the loop at the end so it only shoots once

  • @yuanabreiltungkopanon9006
    @yuanabreiltungkopanon90062 жыл бұрын

    i have been watching you since 2019 can you do mroe base raider videos? i miss you doing them

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

    Can you make a part 2 of making admin commands? it would really help alot of people who wants to make admin commands to make it secure

  • @maciezez

    @maciezez

    Жыл бұрын

    I'm a roblox dev and I have an yt channel and I can make that video

  • @itsemin2131
    @itsemin21312 жыл бұрын

    Now how do i make a gun with muzzle flash, bullet holes etc?

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

    do i need to do the part where it says make a event that detects when you click or can i just add a click detector in the tool

  • @epic4

    @epic4

    Жыл бұрын

    You need the event not a click detector object

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

    It's a good tutorial but i'm having issue where i have to keep looking repeatingly to see what the codes are which thinking you place the code in the description then let people copy then paste it on the command line

  • @epic4

    @epic4

    Жыл бұрын

    I can figure out a way to have a link that has the text so you can just copy from it as you go instead of having to type it which is tiring Edit: It works

  • @felixkranken9675
    @felixkranken96752 жыл бұрын

    How do I set the place it fires, and also looking at where the mouse is pointing, and animations possibly?

  • @felixkranken9675

    @felixkranken9675

    2 жыл бұрын

    @@ryl51db No, I can't script a gun that's literally why I'm here, you want me to examine freemodels?

  • @epic4

    @epic4

    2 жыл бұрын

    while I know how, i wont be able to explain to you since i need to do a remake where you don't have to copy the code so it wont cause people to procrastinate from the amount of work they have to do just to understand, sorry

  • @ftblaze6175

    @ftblaze6175

    2 жыл бұрын

    @@epic4 ill be waiting for the next video , and possibly some mobile functionality , ill be waiting , i met you on noobs vs zombies last time noice

  • @randomidea6436
    @randomidea64362 жыл бұрын

    also can you make a bullets that are not affected by gravity, i mean bullets will travel 100% straight to the mouse

  • @epic4

    @epic4

    2 жыл бұрын

    yea i would just set the gravity where it says "gravity = vector3.new(0,-196.8,0)" to all zeros for no gravity (in both local script and server script)

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

    But how do I add a cross hair and not only click on the screen just like other fps?

  • @john681B
    @john681B2 жыл бұрын

    How bout that ammo system? Also are you sure that there's no way to fix the bullet delay, it just doesn't seem right. also wallbang system

  • @epic4

    @epic4

    2 жыл бұрын

    you cant fix the bullet delay since it takes time for the roblox server to communicate with your computer i plan to do the ammo system in part 3 but i can do the wallbang in part 2 you can fake the lack of bullet delay but its not accurate and people might think when they are killed that the other is hacking

  • @blackpunkcze74
    @blackpunkcze742 жыл бұрын

    could i ask what is the text font you are using?

  • @epic4

    @epic4

    2 жыл бұрын

    for subtitles its arial and for thumbnail its calibri

  • @blackpunkcze74

    @blackpunkcze74

    2 жыл бұрын

    Ok Btw Is The Gun Gonna Have Gun system? Like Settings Where Are Options Like Auto Shotgun Ammo Firerate damage and those things?

  • @personakagex9166
    @personakagex91662 жыл бұрын

    *The first few seconds* Me: alright looks easy, looking good so far *me a while later* "I CAN'T UNDERSTAND WHAT HE'S SAYING"

  • @mushrooms9444
    @mushrooms94442 жыл бұрын

    i dont see any yellow lines coming out of my 4x2x1 block help me please

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

    This helps however can you add a reload feature at part 2?

  • @epic4

    @epic4

    Жыл бұрын

    Yeah I will add it as part of part 2

  • @historicalbacon965

    @historicalbacon965

    Жыл бұрын

    5 months have passed already

  • @forevorhabepno
    @forevorhabepno2 жыл бұрын

    I don't know why, but the bullets don't want to be displayed :( Can you help, please?

  • @TechnoBloxYT
    @TechnoBloxYT2 жыл бұрын

    How can you make it so that you have to click it 1 time and its gonna shoot 1 bullet and not hold to shoot?

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

    is fire function 1:25 is a local function?

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

    can u make how to do animations with the guns?

  • @epic4

    @epic4

    Жыл бұрын

    I plan to do it in a part 2 after I make a remake (and it's the last remake for now, so I'll do part 2 next)

  • @Brecud
    @Brecud2 жыл бұрын

    I get this is about roblox studio and this is about base raiders but how do i make sure my CPU Ghz Rate stays at 3-4 Ghz because when I play base raider, it goes down to 0.78 Ghz and I play BTD6 for several hours and it still stays at 3-4 Ghz

  • @lakulaama
    @lakulaama2 жыл бұрын

    How can i change where it fires the bullet also when parr 2

  • @QUA4DD
    @QUA4DD2 жыл бұрын

    what do i add to userinput service

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

    How can i add spread?

  • @6uspect
    @6uspect2 жыл бұрын

    next video how to add ammo pls

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

    When part 2?

  • @memenadekhanh3992
    @memenadekhanh39922 жыл бұрын

    Does the gun lag if you script like that??

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

    Hello, i need help from you or anyone who know, ive tried to make a gun using your code, ive done well until minute 2:42. But when i tested it it wont damage the dummy and it says "unable to cast value to objects" when did i do wrong to this code local script local player = game.Players.LocalPlayer local userInput = game:GetService("UserInputService") local camera = workspace.CurrentCamera function GetMousePosition(X, Y) local cameraRay = camera:ViewportPointToRay(X, Y) local newRay = Ray.new(cameraRay.Origin, cameraRay.Direction * 500000) local target, position = workspace:FindPartOnRay(newRay, player.Character) return position end local remote = script.Parent:WaitForChild("RemoteEvent",5) userInput.InputBegan:Connect(function(input,gui) if input.UserInputType == Enum.UserInputType.MouseButton1 then local location = userInput:GetMouseLocation() remote:FireServer(GetMousePosition(location.x,location.y)) end end) script local remote = script.Parent.RemoteEvent local handle = script.Parent.Handle remote.OnServerEvent:Connect(function(player,pos) task.spawn(fire,player,pos) end) function fire(player,pos) local startPos = handle.Position local direction = CFrame.new(startPos,pos) local velocity = 1650 direction= direction.LookVector*velocity local range = 3000 local lastPos = startPos local startTime = tick() local rayFilter = RaycastParams.new() rayFilter.FilterDescendantsInstances = (player.Character) rayFilter.FilterType = Enum.RaycastFilterType.Blacklist while range > 0 do local timeLength = (tick()-startTime) local currentPos = startPos + (direction*timeLength) local distance = (lastPos - currentPos).Magnitude range -= distance local ray = workspace:Raycast(lastPos,currentPos-lastPos,rayFilter) if ray == nil then ray = workspace:Raycast(currentPos,lastPos-currentPos,rayFilter) end if ray then local hit = ray.Instance currentPos = ray.Position local model = hit:FindFIrstAncestorOfClass("Model") if model then local humanoid = model:FindFirstChildWhichIsA("Humanoid") or nil if humanoid then if hit.Name == "Head" then humanoid:TakeDamage(100) else humanoid:TakeDamage(80) end end end break end lastPos = currentPos task.wait() end end (Its not done yet btw just until minute 2:42)

  • @dolphinwasorange2585
    @dolphinwasorange25852 жыл бұрын

    There is a glitch where the display bullet disappears on the screen of the person who is killed by it after they respawn. I tried to find a solution to work around this problem however I couldn’t find what was causing this issue. If anyone has any idea how to fix this, help would be deeply appreciated.

  • @epic4

    @epic4

    2 жыл бұрын

    to fix add a screengui into startergui and disable reset on spawn setting in the screengui then you put the bullet render into the screen gui and that should fix it

  • @dolphinwasorange2585

    @dolphinwasorange2585

    2 жыл бұрын

    @@epic4 Thank you for the solution! I appreciate the help!

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

    How do I make the gun not sideways 🔫

  • @faizisair4973
    @faizisair49732 жыл бұрын

    Is there any way to add a sound effect when the players start shooting?

  • @digitaltiger05

    @digitaltiger05

    2 жыл бұрын

    this worked for me first, add a sound directly inside the tool in the script, add this at the beginning: local shotSound = script.Parent.shot and then add this directly after the function fire(player,pos) shotSound:Play()

  • @6uspect

    @6uspect

    2 жыл бұрын

    @@digitaltiger05 omg it worked thx

  • @_Berserker_777

    @_Berserker_777

    2 жыл бұрын

    @@digitaltiger05 yea that didn't work for me

  • @orangenetic
    @orangenetic2 жыл бұрын

    Bullet frenzy remaster when?

  • @rafikelabbassi8233
    @rafikelabbassi82332 жыл бұрын

    how can i make it so the bullets go straight?

  • @epic4

    @epic4

    2 жыл бұрын

    at the gravity part you see where it says "-workspace.Gravity" set it to 0 instead and you have straight bullets

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

    How to fix the lag?

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

    I am having a error called The Parent property of bulletReplicator is locked, current parent: NULL, new parent ReplicatedStorage

  • @el_archi_mago
    @el_archi_mago2 жыл бұрын

    Are you gonna make a second part? I would also like a sword tutorial

  • @epic4

    @epic4

    2 жыл бұрын

    i plan to do the second part after i remake the vid. i also plan to make a melee tutorial since i also completed making the melee

  • @roadsigncheems1566
    @roadsigncheems15662 жыл бұрын

    this tutorial is alright but it lacks actually teaching what lines of code does what and how we can apply it to stuff in the future, instead its just "write this and youll have a gun" its the same as taking a gun from the toolbox

  • @epic4

    @epic4

    2 жыл бұрын

    The "apply to the future" part might not be possible for me to explicitly put, but I am definitely working on the "what lines of code does what" in a remake and it looks good

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

    the mouse is offset a bit

  • @TheDakey12
    @TheDakey122 жыл бұрын

    Every time when I do this part correctly and what you did it keeps on saying error 3:48

  • @epic4

    @epic4

    2 жыл бұрын

    What does the error say

  • @randomidea6436
    @randomidea64362 жыл бұрын

    Its better to do a video about making gun with voice explaination my friend, i will subscribe if you do what i had suggested on yah

  • @KrakenJudeStudios
    @KrakenJudeStudios2 жыл бұрын

    Hi Please Part 2 Ammo Please

  • @A_Basement
    @A_Basement2 жыл бұрын

    is there a way i can make it fire multiple bullets, like a shotgun

  • @jaidwe

    @jaidwe

    2 жыл бұрын

    local bulletsCount=6 for i=1,bulletsCount do end you will also need to make the bullets fly in random directions

  • @_Berserker_777

    @_Berserker_777

    2 жыл бұрын

    @@jaidwe Okay but where do you have to put the script?

  • @jaidwe

    @jaidwe

    2 жыл бұрын

    ​@@_Berserker_777 script that responds for raycasting and making bullets (there may be more than just 1 script) to make sure everything will work for you i will need to watch this video again after 2 months (i didnt actually try to make a gun with this tutorial)... heres a quick example: function fire() --normal script raycast() createBullet() end local repeatCount=4 function fire2() --script with "for i" loop" for i=1,repeatCount do raycast() createBullet() end end

  • @notsharing5887
    @notsharing58872 жыл бұрын

    ah, the bullet is slow. What did I do wrong?

  • @scrude657
    @scrude6572 жыл бұрын

    i my brain cant process it ill try my best to read and follow it atleast understand it

  • @epic4

    @epic4

    2 жыл бұрын

    yeah i also notice how one of my friends feel the same thing so ill try to make another vid where you don't have to copy the code (ill still show code) and show a lot more in visuals how the code works

  • @scrude657

    @scrude657

    2 жыл бұрын

    @@epic4 im gonna learn it tmrw since its late here lol, im trying to make a musket (northwind inspired system)

  • @epic4

    @epic4

    2 жыл бұрын

    Nice good luck and thanks for the feedback

  • @dogebread5263
    @dogebread52632 жыл бұрын

    lol

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

    1:08

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

    1:46

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

    why the bullet not showing even tho i typed the right script in BulletRender local remotes = {} function getRemote(remote) if remote:IsA("RemoteEvent") and remote.Name == "bulletReplicator" then for _,storedRemote in pairs(remotes) do if storedRemote == remote then return end end table.insert(remote,remote) remote.OnClientEvent:Connect(fire) end end for _,remote in pairs(game.ReplicatedStorage:GetChildren()) do getRemote(remote) end game.ReplicatedStorage.ChildAdded:Connect(function(remote) getRemote(remote) end) local bulletStorage = Instance.new("Folder",workspace) bulletStorage.Name = "bulletStorage" function fire(character,startPos,direction,range) local lastPos = startPos local startTime = tick() local bullet = Instance.new("Part") bullet.Size = Vector3.new(0.1,0.1,0.4) bullet.Anchored = true bullet.CanCollide = false bullet.BrickColor = BrickColor.new("New Yeller") bullet.Material = Enum.Material.Neon bullet.Position = startPos bullet.Parent = bulletStorage local rayFilter = RaycastParams.new() rayFilter.FilterDescendantsInstances = {character,bulletStorage} rayFilter.FilterType = Enum.RaycastFilterType.Blacklist while range > 0 do local timeLength = (tick()-startTime) local currentPos = startPos + (direction+timeLength) local distance = (lastPos - currentPos).Magnitude range -= distance local ray = workspace:Raycast(lastPos,currentPos-lastPos,rayFilter) if ray == nil then ray = workspace:Raycast(currentPos,lastPos-currentPos,rayFilter) end if ray then local hit = ray.Instance currentPos = ray.Position end bullet.CFrame = CFrame.new(currentPos,lastPos)*CFrame.new(0, 0, -(lastPos-currentPos).magnitude/2) bullet.Size = Vector3.new(.1, .1,(lastPos-currentPos).Magnitude) if ray then break end lastPos = currentPos task.wait() end task.wait() bullet:Destroy() end

Келесі