of     1   

acer1102
#228414366Monday, December 04, 2017 3:11 AM GMT

I've been working on a inventory/weapon script for quite some time and recently i was trying to ### in a burst fire mode for it. It worked for the most part but was buggy if you spammed. Attempting to fix this only made my situation worse causing the game to crash. I know what code is causing the game to crash I just don't know why. P.S., I'm not using a Tool ===============Code=============== local CanFire = true local BurstCount = 5 local function Fire(Weapon) if Weapon.Settings.CurrentMagSize.Value > 0 then CanFire = true local Effects = Weapon:WaitForChild("Effects") if not Weapon.Model.Barrel:FindFirstChild("Smoke") then _G.Smoke = Effects.Smoke:Clone() _G.Smoke.Parent = Weapon.Model.Barrel repeat if CanFire == true then Weapon.Settings.CurrentMagSize.Value = Weapon.Settings.CurrentMagSize.Value - 1 BurstCount = BurstCount - 1 _G.Smoke.Enabled = true wait() _G.Smoke.Enabled = false wait(0.05) CanFire = false end until BurstCount == 0 wait(0.5) CanFire = true BurstCount = 5 else repeat if CanFire == true then Weapon.Settings.CurrentMagSize.Value = Weapon.Settings.CurrentMagSize.Value - 1 BurstCount = BurstCount - 1 _G.Smoke.Enabled = true wait() _G.Smoke.Enabled = false wait(0.05) CanFire = false end until BurstCount == 0 wait(0.5) CanFire = true BurstCount = 5 end elseif Weapon.Settings.CurrentMagSize.Value <= 0 then CanFire = false Reload(player.Character.Inventory:FindFirstChild(currentWeapon.Name)) wait(1) CanFire = true end end ============================================= Should I use a different type of loop?
acer1102
#228414658Monday, December 04, 2017 3:21 AM GMT

Bump
Exzeption
#228414768Monday, December 04, 2017 3:24 AM GMT

When you have the repeats with the conditional statements inside, be sure to add an else wait()
acer1102
#228414837Monday, December 04, 2017 3:27 AM GMT

Well it's not crashing now but it's bugged worse than it was before.
ExtremeBuilder15
#228415158Monday, December 04, 2017 3:38 AM GMT

I think you need to make a debounce that stops you from having two bursts going at the same time local shooting = false function fire() if not shooting then shooting = true --Rest of code shooting = false -- After you're done shooting, reset the shooting variable else -- Do nothing end end

    of     1