How would i add a reloading system for this script?

alright so i got a gun, its automatic but idk how to add a reloading system to it. there are 2 scripts. the first one is the local script:

local gun = script.Parent

local gun_shot = gun["Gun Shot"]


local ReplicatedStorage = game:GetService('ReplicatedStorage')

local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')


local shooting = false

local equipped = false


local player = game.Players.LocalPlayer

local mouse = player:GetMouse()


local mouseConnection


gun.Equipped:Connect(function()



	equipped = true




	mouseConnection = mouse.Button1Down:Connect(function()

		shooting = true

		while shooting and equipped do

			remoteEvent:FireServer(gun.Handle.Position, gun.Handle.Orientation, mouse.Hit.p)

			gun_shot:Play()

			mouse.Button1Up:Connect(function()

				shooting = false

			end)

			wait(0.1)

		end

	end)

end)


gun.Unequipped:Connect(function()

	equipped = false

	mouseConnection:Disconnect()

end)

now here’s the serverscriptservice:

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')


local damage_amount = 10


remoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)



	local bullet = Instance.new('Part')

	bullet.Name = 'Bullet'

	bullet.Parent = game.Workspace

	bullet.Shape = Enum.PartType.Cylinder

	bullet.Size = Vector3.new(0.25, 0.25, 0.25)

	bullet.BrickColor = BrickColor.new('White')



	local speed = 250

	bullet.CFrame = CFrame.new(gunPos, mosPos)

	bullet.Velocity = bullet.CFrame.lookVector * speed



	bullet.Touched:Connect(function(otherPart)

		local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

		if humanoid and humanoid.Parent.Name ~= player.Name then

			if humanoid.Health > 0 and humanoid.Health - damage_amount <= 0 then

			end

			humanoid:TakeDamage(damage_amount)

			bullet:Destroy()

		end

	end)



	game:GetService('Debris'):AddItem(bullet, 1)

end)