Hello Roblox Community,
I recently started to learn scripting by fiddling around with scripts i find and i am working on this weapon script and modificating it and i have a problem
So this gun script has a jamming feature however the jam feature gets only triggered when the player presses the mousebutton down not per shot from the gun so i took
the code wich made it jamable by chance and put it into the gun fired and that also works
however the gun keeps shooting even tho the jammed variable gets changed into “true”
i want it to stop shooting once the variable jammed gets changed to true
i currently also use the commentary way to “disable” some lines of code wich i copied and put somewhere else so i dont have to return or incase i mess up
Mouse.Button1Down:connect(function()
Down = true
local IsChargedShot = false
if Equipped and Enabled and Down and not Jammed and not Reloading and Ammo > 0 and Humanoid.Health > 0 then
Enabled = false
--if not Jammed then
--if Chance(Module.JamChance) == true then
--Jammed = true
--end
--end
if Module.ChargedShotEnabled then
if HandleToFire:FindFirstChild("ChargeSound") then HandleToFire.ChargeSound:Play() end
wait(Module.ChargingTime)
IsChargedShot = true
end
if Module.MinigunEnabled then
if HandleToFire:FindFirstChild("WindUp") then HandleToFire.WindUp:Play() end
wait(Module.DelayBeforeFiring)
end
while Equipped and not Reloading and not PullingOut and (Down or IsChargedShot) and Ammo > 0 and Humanoid.Health > 0 do
IsChargedShot = false
for i = 1,(Module.BurstFireEnabled and Module.BulletPerBurst or 1) do
spawn(ShakeCamera)
for x = 1,(Module.ShotgunEnabled and Module.BulletPerShot or 1) do
Fire(HandleToFire)
end
Ammo = Ammo - 1
ChangeAmmoAndClip:FireServer(Ammo,Clips)
UpdateGUI()
script.Parent.Bolt.Transparency = 1
script.Parent.BoltBack.Transparency = 0
if Module.BurstFireEnabled then wait(Module.BurstRate) end
wait(0.05)
script.Parent.Bolt.Transparency = 0
script.Parent.BoltBack.Transparency = 1
if Ammo <= 0 then break end
if Jammed then break end
end
HandleToFire = (HandleToFire == Handle and Module.DualEnabled) and Handle2 or Handle
wait(Module.FireRate)
if not Module.Auto then break end
end
if HandleToFire.FireSound.Playing and HandleToFire.FireSound.Looped then HandleToFire.FireSound:Stop() end
if Module.MinigunEnabled then
if HandleToFire:FindFirstChild("WindDown") then HandleToFire.WindDown:Play() end
wait(Module.DelayAfterFiring)
end
ObjectEdit:FireServer(Handle, 'GunFiredFinal')
Enabled = true
elseif Equipped and Enabled and Down and not Reloading or Jammed and Ammo <= 0 and Humanoid.Health > 0 then
--Reload()
ObjectEdit:FireServer(Handle, 'GunEmpty')
end
end)
Mouse.Button1Up:connect(function()
Down = false
end)