I nead help with my gun script

Hello everyone I am making a gun system and I some time the animation when i shoot just stop for some time and afther play again

Here a video:

Here is the code:

Client script:

local eq = false
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local HitSound = game.SoundService:WaitForChild('Hit')
script.Parent.Equipped:Connect(function()
	eq = true
end)
script.Parent.Unequipped:Connect(function()
	
		eq = false

end)
local cooldown = false
local Damage = 30
local FireRate = 0.12
mouse.Button1Down:Connect(function()
	if eq == true then
		local Target1 = mouse.Target
		if cooldown == false then
			script.Parent.PlaySound:FireServer()
			if Target1 == nil then

				
				print('No Model')
				cooldown = true
				script.Parent.ShootEvent:FireServer()

				wait(FireRate)
				cooldown = false

			elseif Target1.Parent.Parent.ClassName == 'Model' then
				local Event = Target1.Parent.Parent:WaitForChild('Damage')
				Event:FireServer(Damage)
				cooldown = true
				script.Parent.ShootEvent:FireServer()
				print(Target1:GetFullName())

				if Target1.Parent.Parent:WaitForChild('Humanoid') then
					HitSound:Play()
				end


				wait(FireRate)
				cooldown = false

			elseif Target1.Parent.ClassName == 'Model' then
				local Event = Target1.Parent:WaitForChild('Damage')
				Event:FireServer(Damage)
				cooldown = true
				script.Parent.ShootEvent:FireServer()
				print(Target1:GetFullName())
				if Target1.Parent:WaitForChild('Humanoid') then
					HitSound:Play()
				end

				wait(FireRate)
				cooldown = false

				


			else
				print('No Model')
				cooldown = true
				script.Parent.ShootEvent:FireServer()

				wait(FireRate)
				cooldown = false

			end
		end

	end
	
end)

Server script:

local ShootEvent = script.Parent.ShootEvent
local PlaySound = script.Parent.PlaySound

local ShootSound = script.Parent.Flame:WaitForChild('FireSound')


local onReload = script.Parent:WaitForChild("OnReload")
local flame = script.Parent:WaitForChild('Flame')

local tool = script.Parent
local reloadAnim = tool:WaitForChild("Reload")

local ammo = script:WaitForChild("Ammo")
local maxammo = script.MaxAmmo.Value
local idleAnimTrack
local shootAnim = tool:WaitForChild("Shoot")
local idleAnim = tool:WaitForChild("Idle")

local firstEquipped = false

script.Parent.Equipped:Connect(function()
	local ammoGui = script.AmmoGui:Clone()
	ammoGui.AmmoStatus.Text = ammo.Value .. "/30"
	ammoGui.GunName.Text = tool.Name

	ammoGui.Parent = game.Players:GetPlayerFromCharacter(tool.Parent).PlayerGui
	if not idleAnimTrack then idleAnimTrack = tool.Parent.Humanoid:LoadAnimation(idleAnim) end

	if not idleAnimTrack.IsPlaying then idleAnimTrack:Play() end
end)
script.Parent.Unequipped:Connect(function()
	
	if idleAnimTrack and idleAnimTrack.IsPlaying then idleAnimTrack:Stop() end

end)

local fired = false
local firedTime = 0
local fireRate = .1
local isReloading = false
local reloadAnim = tool:WaitForChild("Reload")

local function reload()

	if isReloading or ammo.Value == 30 then return end
	isReloading = true



	local reloadAnimTrack = tool.Parent.Humanoid:LoadAnimation(reloadAnim)
	--idleAnimTrack:Stop()
	reloadAnimTrack:Play()
	wait(0.75)
	--reloadSound:Stop()
	--reloadSound.TimePosition = 0
	--idleAnimTrack:Play()

	ammo.Value = maxammo

	isReloading = false


end
local function FXon()
	for i, flashPart in pairs(flame:GetChildren()) do

		if flashPart.Name == 'FlashFX' then flashPart.Enabled = true end
		if flashPart.Name == 'FlashFXFlash' then flashPart.Enabled = true end
		if flashPart.Name == 'OverHeat' then flashPart.Enabled = true end
		if flashPart.Name == 'Smoke' then flashPart.Enabled = true end
		if flashPart.Name == 'Smoke2' then flashPart.Enabled = true end
	end
end

local function FXoff()
	for i, flashPart in pairs(flame:GetChildren()) do

		if flashPart.Name == 'FlashFX' then flashPart.Enabled = false end
		if flashPart.Name == 'FlashFXFlash' then flashPart.Enabled = false end
		if flashPart.Name == 'OverHeat' then flashPart.Enabled = false end
		if flashPart.Name == 'Smoke' then flashPart.Enabled = false end
		if flashPart.Name == 'Smoke2' then flashPart.Enabled = false end
	end
end
ShootEvent.OnServerEvent:Connect(function(player)
	if isReloading then return end
	if ammo.Value < 1 then

		reload()

		return
	end

	if game.Players:GetPlayerFromCharacter(script.Parent.Parent) ~= player then
		return
	end
	if player.Character:FindFirstChildOfClass("Humanoid").Health == 0 then
		return
	end
	

		fired = true
		--firedTime = tick()



		tool.Parent.Humanoid:LoadAnimation(shootAnim):Play()

		ammo.Value = ammo.Value - 1

	fired = false


	


end)
ShootEvent.OnServerEvent:Connect(function()
	FXon()
	wait(0.006)
	FXoff()
end)

PlaySound.OnServerEvent:Connect(function()
	ShootSound:Play()
end)

Damage receiver (in starter character script):

local Event = script.Parent:WaitForChild('Damage')

Event.OnServerEvent:Connect(function(plr, Damage)

local Humanoid = script.Parent:WaitForChild('Humanoid')

Humanoid:TakeDamage(Damage)

print(Damage)

end)

thank you in advance!

i have an potential idea for why this happend it’s probably because of the number of remote event