Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make my gun shoot two times at the same time?

Asked by
Mr_Unlucky 1085 Moderation Voter
5 years ago

Im making a dual wielding gun tool, but I'm trying to figure out how to make it shoot at the same time. Can someone tell me? CODE:

local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
        local touch, position = workspace:FindPartOnRay(ray, game.Players.LocalPlayer.Character, false, true)
        local trace = Instance.new("Part")
        trace.Anchored = trace
        trace.CanCollide = false
        trace.Transparency = 0.5
        trace.BrickColor = BrickColor.new("Black")
        trace.Material = Enum.Material.SmoothPlastic
        local distance = (tool.Handle.CFrame.p - position).magnitude
        trace.Size = Vector3.new(0, 0, distance)
        trace.CFrame = CFrame.new(tool.Handle.CFrame, position) * CFrame.new(0, 0, -distance / 2)
        trace.Parent = workspace
0
note that this code describes how it's going to shoot Mr_Unlucky 1085 — 5y
0
What exactly are you having trouble with? To make it shoot twice you could just put this in a small for loop. theCJarmy7 1293 — 5y
0
try for i = 1, 2, 1 do (Raycasting code here) end YouSNICKER 131 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I am assuming you mean shooting two seperate bullets at the same time from TWO SEPERATE guns, just in the same tool(1 tool, a gun model for each arm). What you could do is just copy and paste your code creating the Ray and the visible part. However, you would see both rays in the same spot, so you wouldn’t really see both. You need to create one Ray from a part on the tip of 1 gun all the way to the mouse, and one Ray from the tip of 2 gun to the mouse, and then have the visible part for each Ray. This would essentially be the same code as you have above, just one for each gun model, but in the same tool. Make sense?

Ad

Answer this question