I have an automatic gun system, but I’m running into the issues on client with animation spam, that if you spam click then animations will be spammed. Like it plays new animation before old one ends. I really don’t know how to explain it, so here’s a video of what i mean by “spam”:
Local script:
local firing = false
function shoot()
if not firing then
if ammo > 0 then
firing = true
repeat
local camera = workspace.CurrentCamera
camera.CFrame:Lerp(camera.CFrame * CFrame.Angles(1, 0, 0), 0.3)
event:FireServer(camera.CFrame.Position, camera.CFrame.LookVector)
task.spawn(function()
fx1.Enabled = true
fx2.Enabled = true
task.wait(0.09)
fx1.Enabled = false
task.wait(0.5)
fx2.Enabled = false
end)
shootAnim:Play()
task.wait(0.2)
until not firing
end
else
firing = false
end
end
tool.Equipped:Connect(function()
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
cas:BindAction("Shoot", shoot, true, Enum.UserInputType.MouseButton1)
cas:SetTitle("Shoot", "Shoot")
cas:SetPosition("Shoot", UDim2.new(0.15, 0, 0.2, 0))
end)
How can I make a cooldown for this or something like that? Thanks in advance.