local jammed = false
ismobile = userInputService.TouchEnabled
iscomputer = userInputService.KeyboardEnabled
-- Reload Function
local function reload ()
if reloading == false then
reloading = true
ReloadAnim = tool:WaitForChild("Reload")
ReloadTrack = hum:LoadAnimation(ReloadAnim)
ReloadTrack:Play()
local part = script.Parent.Handle.mag:Clone()
part.Position = tool.Handle.mag.Position
part.CFrame = tool.Handle.CFrame * CFrame.Angles(0, math.rad(90), 0)
part.Parent = workspace
part.CanCollide = true
part.BrickColor = BrickColor.new("Smoky grey")
part.Material = Enum.Material.Metal
script.Parent.Handle["Gun Reload"]:Play()
script.Parent.Handle.mag.Transparency = 1
tool.Parent:WaitForChild("run?").Value = false
tool.Parent:WaitForChild("Humanoid").WalkSpeed = 10
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
task.wait(3)
local random = math.random(1,2)
if random == 1 then
print("gunnotjammed")
else
jammed = true
script.Parent.Handle.JAMMED:Play()
print("gungotjammed")
end
tool.Parent:WaitForChild("run?").Value = true
tool.Parent:WaitForChild("Humanoid").WalkSpeed = 17
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
script.Parent.Handle.mag.Transparency = 0
ammo = maxAmmo
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Text = ""..ammo.."/"..maxAmmo
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Transparency = 0
if ReloadTrack then
ReloadTrack:Stop()
end
reloading = false
wait(4)
part:Destroy()
end
end
-- Shooting function
local function shoot()
if iscomputer then
if not tool:IsDescendantOf(player.Character) then return end
local Time = tick()
if Time - lastShot >= shotDelay then
lastShot = Time
if debounce == false and ammo > 0 and reloading == false and holding == true and jammed == false then
debounce = true
local maths = math.random(5,7)
local maf = math.random(1,2)
ammo -= 1
tool.Shoot:FireServer(mouse.Hit.Position)
if shotanimtrack then
shotanimtrack:Play()
end
if maf == 1 then
script.Parent.Handle.Barrel["Gun shot"]:Play()
script.Parent.Handle.Barrel["Gun shot"].Volume = maths
print(maths)
elseif maf == 2 then
script.Parent.Handle.Barrel["Gun shot2"]:Play()
script.Parent.Handle.Barrel["Gun shot2"].Volume = maths
print(maths)
end
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(2),0,0)
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Text = ""..ammo.."/"..maxAmmo
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Transparency = 0
task.wait(0.09)
debounce = false
elseif ammo <= 0 and reloading == false then
reload()
end
end
end
end
local function moblieshooting()
if ismobile then
if not tool:IsDescendantOf(player.Character) then return end
if debounce == false and ammo > 0 and reloading == false and jammed == false then
debounce = true
ammo -= 1
tool.Shoot:FireServer(mouse.Hit.Position)
if shotanimtrack then
shotanimtrack:Play()
end
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(2),0,0)
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Text = ""..ammo.."/"..maxAmmo
player.PlayerGui.AmmoGui3.Frame3.TextLabelg.Transparency = 0
task.wait(0.09)
debounce = false
elseif ammo <= 0 and reloading == false then
reload()
end
end
end
this isn’t the full local script but its where it does the shooting for mobile, i have no idea why this happens tho, like if i touch the screen it only shoots once which i want to happen but if i test the game again and touch the screen it doesn’t shoot anymore for some weird reason there’s no error it just happens



