Help with reload system


I create a beam that shoots but it shoots endlessly, I need that the beam would shoot once every 2 seconds but how to do it I can not understand, I tried to use script.Enabled = false, but after a couple of seconds the beam fired several times in a row, if you know how you can do reloading, can you tell me please.
the script:

local RS = game:GetService("ReplicatedStorage")
local Team  = game:GetService("Teams")
local Starterplayer = game:GetService("StarterPlayer")
local muchachoHb = require(RS.Modules.MuchachoHitbox)

local remoteEvent = RS:WaitForChild("Remotes"):WaitForChild("RemoteEvent")

local duration = 2

local damage = 5
local amount = 7


remoteEvent.OnServerEvent:Connect(function(player, act)
	local char = player.Character
	local hum = char.Humanoid
	local humr = char.HumanoidRootPart
	
	if act == "Charge" then
		remoteEvent:FireAllClients(player.Character, "Charge")
	elseif act == "Beam" then
		print("work")
		local hitbox = muchachoHb.CreateHitbox()
		hitbox.CFrame = humr.CFrame * CFrame.new(0, 0, -27.5)
		hitbox.Size = Vector3.new(5, 5, 55)
		hitbox.Visualizer = false
		hitbox.AutoDestroy = false
		
		hitbox.Touched:Connect(function(hit, ehum)
			if ehum ~= hum then
				ehum:TakeDamage(damage)
			end
		end)
		task.spawn(function()
			for i=1, amount do
				task.wait(0.1)
				hitbox:Start()
				task.wait(0.15)
				hitbox:Stop()
			end
		end)
		
	
			
		end
		remoteEvent:FireAllClients(player.Character, "Beam")
		
		task.delay(duration, function()
			hum.WalkSpeed = 16
			hum.JumpHeight = 7.2
		
		end)
end)

local script:

local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local Tweens = game:GetService("TweenService")
local serversound = RS.Sound
local plr = game:GetService("Players").LocalPlayer
local Team = game:GetService("Teams")


local cameraShaker = require(RS.Modules.CameraShaker)

local camShake = cameraShaker.new(Enum.RenderPriority.Camera.Value, function(ShakeCFrame)
	workspace.CurrentCamera.CFrame *= ShakeCFrame
end)

local remoteEvent = RS:WaitForChild("Remotes"):WaitForChild("RemoteEvent")

local duration = 2
local VFXFolder = RS.Effects.Kameha

UIS.InputBegan:Connect(function(inp, ist)
	if ist then return end
	if inp.KeyCode == Enum.KeyCode.F and plr.Team == Team.Played then
		remoteEvent:FireServer("Charge")
	end
end)

UIS.InputEnded:Connect(function(inp, ist)
	if ist then return end
	if inp.KeyCode == Enum.KeyCode.F and plr.Team == Team.Played then
		remoteEvent:FireServer("Beam")
	end
end)


remoteEvent.OnClientEvent:Connect(function(character, act)
	if act == "Charge" then
		
		local HumAnim = Instance.new("Animation")
		HumAnim.AnimationId = "rbxassetid://18399795401"
		local anim = character.Humanoid:LoadAnimation(HumAnim)
		anim:Play()
		
		serversound.LaserSound:Play()
		local vfx = VFXFolder.Charge.Charge:Clone()
		vfx.Parent = character["RightHand"]
	elseif act == "Beam" then
		serversound.Gunsound:Play()
		camShake:Start()
		task.spawn(function()
			for i=1, math.random(8, 9) do
				camShake:ShakeOnce(3, 15, 0.15, 0.15)
				task.wait(0.35)
			end
		end)
		
		local ccwhite = VFXFolder.KamehaWhite:Clone()
		ccwhite.Parent = game.Lighting
		ccwhite.Enabled = true
		
		local ccblack = VFXFolder.KamehaBlack:Clone()
		ccblack.Parent = game.Lighting
		ccblack.Enabled = false
		
		task.delay(0.04, function()
			ccwhite.Enabled = false
			ccblack.Enabled = true
			task.wait(0.025)
			ccblack.Enabled = false
			ccwhite.Enabled = true
			task.wait(0.05)
			ccwhite.Enabled = false
			ccblack.Enabled = false
			ccwhite:Destroy()
			ccblack:Destroy()
			
		end)
		
		local beam = VFXFolder.Beam:Clone()
		beam.Attachment0.WorldCFrame = character["RightHand"].CFrame
		beam.Attachment1.WorldCFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,0,-55)
		beam.Parent = workspace
		
		task.delay(duration, function()
			for _, particle in character:GetDescendants() do
				if particle:IsA("ParticleEmitter") then
					particle.Rate = 0
				end
			end
			
			for _, effect in beam:GetDescendants() do
				if effect:IsA("ParticleEmitter") then
					effect.Rate = 0
				end
				if effect:IsA("Beam") then
					local tw1 = Tweens:Create(effect, TweenInfo.new(0.8), {Width0 = 0}):Play()
					local tw2 = Tweens:Create(effect, TweenInfo.new(0.8), {Width1 = 0}):Play()
				end
			end
		
			debris:AddItem(character["RightHand"].Charge, duration + 2)
			
			
		end)
		debris:AddItem(beam, duration + 1)
		end
	end)

I need someone to tell me how to do a “Reload” system.

1 Like