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
the legend is back, glad you are still active!
really good work i love guns like this ty for help
You have learned
YOOO THE LEGEND IS BACK LES GO!!!
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)
Underrated channel
This is gonna be lit
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!
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
2 жыл бұрын
i tried to make the text like its "seamless talking" so its like a constant flow of information without being bored
@JoSeph-qo4gq
2 жыл бұрын
@@epic4 Well it kind of worked but it has room for improvment
@noxusnobos6541
2 жыл бұрын
@@epic4 hey when you put a server script in the tool hackers can access it though
@KLEY_
2 жыл бұрын
@@noxusnobos6541 no because server script is working on server not local
@noxusnobos6541
2 жыл бұрын
@@KLEY_ k
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
I miss ur base raiders vid cuz I love ur design I rate it 1000000/10 I hope u back play base raiders man
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
this is the best
nice
Quick question, will you make more noobs v zombies content?
@epic4
2 жыл бұрын
Probably but I need video ideas
Please make part 2. I liked your video and sub your channel.
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
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
i have been watching you since 2019 can you do mroe base raider videos? i miss you doing them
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
Жыл бұрын
I'm a roblox dev and I have an yt channel and I can make that video
Now how do i make a gun with muzzle flash, bullet holes etc?
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
Жыл бұрын
You need the event not a click detector object
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
Жыл бұрын
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
How do I set the place it fires, and also looking at where the mouse is pointing, and animations possibly?
@felixkranken9675
2 жыл бұрын
@@ryl51db No, I can't script a gun that's literally why I'm here, you want me to examine freemodels?
@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
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
also can you make a bullets that are not affected by gravity, i mean bullets will travel 100% straight to the mouse
@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)
But how do I add a cross hair and not only click on the screen just like other fps?
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
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
could i ask what is the text font you are using?
@epic4
2 жыл бұрын
for subtitles its arial and for thumbnail its calibri
@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?
*The first few seconds* Me: alright looks easy, looking good so far *me a while later* "I CAN'T UNDERSTAND WHAT HE'S SAYING"
i dont see any yellow lines coming out of my 4x2x1 block help me please
This helps however can you add a reload feature at part 2?
@epic4
Жыл бұрын
Yeah I will add it as part of part 2
@historicalbacon965
Жыл бұрын
5 months have passed already
I don't know why, but the bullets don't want to be displayed :( Can you help, please?
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?
is fire function 1:25 is a local function?
can u make how to do animations with the guns?
@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)
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
How can i change where it fires the bullet also when parr 2
what do i add to userinput service
How can i add spread?
next video how to add ammo pls
When part 2?
Does the gun lag if you script like that??
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)
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
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
2 жыл бұрын
@@epic4 Thank you for the solution! I appreciate the help!
How do I make the gun not sideways 🔫
Is there any way to add a sound effect when the players start shooting?
@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
2 жыл бұрын
@@digitaltiger05 omg it worked thx
@_Berserker_777
2 жыл бұрын
@@digitaltiger05 yea that didn't work for me
Bullet frenzy remaster when?
how can i make it so the bullets go straight?
@epic4
2 жыл бұрын
at the gravity part you see where it says "-workspace.Gravity" set it to 0 instead and you have straight bullets
How to fix the lag?
I am having a error called The Parent property of bulletReplicator is locked, current parent: NULL, new parent ReplicatedStorage
Are you gonna make a second part? I would also like a sword tutorial
@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
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
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
the mouse is offset a bit
Every time when I do this part correctly and what you did it keeps on saying error 3:48
@epic4
2 жыл бұрын
What does the error say
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
Hi Please Part 2 Ammo Please
is there a way i can make it fire multiple bullets, like a shotgun
@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
2 жыл бұрын
@@jaidwe Okay but where do you have to put the script?
@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
ah, the bullet is slow. What did I do wrong?
i my brain cant process it ill try my best to read and follow it atleast understand it
@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
2 жыл бұрын
@@epic4 im gonna learn it tmrw since its late here lol, im trying to make a musket (northwind inspired system)
@epic4
2 жыл бұрын
Nice good luck and thanks for the feedback
lol
1:08
1:46
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