So, my script is broken which I already knew - how, is because it wont reload when I've held my mouse down for more than 10 seconds. It never does reload, I don't know why or how. Please, if you are smart enough and aren't busy, please help out. any little thing works.

local mousedown = false
local plr = game.Players.LocalPlayer
local tool = script.Parent
local ammo = 30
local mags = 10
local debounce = false
local mouse = game.Players.LocalPlayer:GetMouse()
local target = mouse.Target
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, plr.Character, false, true)
		
function fire()
	if target ~= nil and ammo >0 then
	
	print("pew")
	tool.Handle.AK:Play()
	game.ReplicatedStorage.shootGun:FireServer(target,"AK47")
	game.ReplicatedStorage.createRay:FireServer(ray,part,position,tool)
	elseif target ~= nil or target == nil and ammo == 0 then
		reload()
	end
	end

function reload()
	if ammo == 0 and mags >0 then
		debounce = true
		mags = mags -1
		tool.Handle.Reload:Play()
		wait(tool.Handle.Reload.TimeLength)
		ammo = 30
		debounce = false
	end
end

tool.Activated:Connect(function()
	if ammo >0 and debounce == false then
		
	
	mousedown = true
	print("Activated")
	repeat fire()
		wait(.1)
	until not mousedown
	else
			reload()
		end
end)

tool.Deactivated:Connect(function()
	mousedown = false
	print("Deactivated")
end)