How to make Burst firemode?

I have this FAMAS gun, but I don’t know how to make it fire in burst. I’ve got this semi-automatic firing system that I can add delays to, but I don’t know how to make it fire three bullets instead of 1. Help? The code is way too big to share, so I’ll just post parts that you request to see.

To clarify: i’ve tried loops on the making the bullet part, but it just breaks the gun

1 Like

You could use a simple loop like a for loop or something

local bulletPerBurst = -- how many bullets you want to fire each burst
local rpm = -- how fast the gun fires, amount per minute

for count = 1, bulletPerBurst do
    -- do firing gun code here
    wait(60/rpm)
end
2 Likes

i mean by like how do i make a loop work for my gun. i’ve found an older version of it that isn’t FE and it places the same line of code where I put it and the nonFE can shoot, but my newer version just breaks

old code:

if MyMouse then
				for i = 1,12 do --shotgun effect
					local targetPoint = MyMouse.Hit.p
					local shootDirection = (targetPoint - Handle.Position).unit
					-- Adjust the shoot direction randomly off by a little bit to account for recoil
					shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
																	(0.5 - math.random()) * 2 * Spread,
																	(0.5 - math.random()) * 2 * Spread) * shootDirection
					local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
					local bullet

Not sure if this is related but your math.random() parameters are empty, making the spread the same everytime.

new code:

if MyMouse then
				for i = 1,12 do --shotgun effect
				RecoilTrack:Play()
				local targetPoint = MyMouse.Hit.p
				local shootDirection = (targetPoint - Handle.Position).unit
				-- Adjust the shoot direction randomly off by a little bit to account for recoil
				shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread,
																(0.5 - math.random()) * 2 * Spread) * shootDirection
				
				Camera.CFrame = Camera.CFrame * CFrame.Angles(0.007,math.rad(0),0)
				
				local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
				local bullet

You could make a cloned fire script and change it up a bit. Then using the key clicking a script disabling. Add an animation too maybe

Do you have full auto guns working?

yeah i do. but i’m not sure i think it’s code just has it loop the firing until the player lets go of the mouse, not fire in shorts of bullets