“cannot resume dead coroutine” is the error I got in this code
local RS = game:GetService("ReplicatedStorage")
local CameraShaker = require(RS.Modules:WaitForChild("CameraShaker"))
local debounce = false
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://13470967554"
local track1 = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(Anim)
--Settings--
local Cooldown = 8
local Cooldown2 = 8 --just for the countdown (has to be the same as the first Cooldown)
local ToolBarHideTime = 3
--Settings--
local countdown = coroutine.wrap(function()
for i=Cooldown2, 0, -1 do
script.Parent.Name = "Cooldown: ".. i
task.wait(1)
if i == 0 then
script.Parent.Name = "Barrage"
Cooldown2 = Cooldown
debounce = false
end
end
end)
script.Parent.Equipped:Connect(function()
if debounce == false then
debounce = true
RS.Events.Barrage:FireServer()
track1:Play()
countdown() -- here is the error
task.wait(Cooldown)
--debounce = false
end
end)
RS.Events.Barrage.OnClientEvent:Connect(function()
game:GetService("Lighting").BlurEffect.Size = 5
game:GetService("TweenService"):Create(game:GetService("Lighting").BlurEffect, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0), {Size = 0}):Play()
local Shakes = script.ShakeScript:Clone()
Shakes.Parent = game:GetService("Players").LocalPlayer.Character
Shakes.Disabled = false
game.Debris:AddItem(Shakes,3)
end)
script.Parent.Equipped:Connect(function()
if debounce == false then
game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
task.wait(ToolBarHideTime)
game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
track1:Stop()
end
end)
but I don’t really know what that means and how to fix it.
can someone help me?