Cooldown not working

The cooldown is just not working it’s so broken, it works, and then it slowly starts to not work.

local firework = script.Parent
local fireworkModel = game:GetService("ServerStorage").Fireworks.RedFirework
local height = 10
local speed = 1
local TweenService = game:GetService("TweenService")
local debounce = false
local timeCooldown = 0

function Launch()
	local character = script.Parent.Parent
	local fwork = fireworkModel:Clone()
	timeCooldown = 0
	debounce = true
	fwork.Parent = game.Workspace
	fwork:MoveTo(character.HumanoidRootPart.Position)
	for i = 0, height*10 do
		fwork:PivotTo(fwork:GetPivot() + Vector3.new(0,1,0))
		wait(0.01)
		if timeCooldown >= 5 then
			debounce = false
		end
		timeCooldown += 0.1
	end
	local explosion = Instance.new("Explosion")
	explosion.Parent = game.Workspace
	explosion.Position = fwork.Body.Position
	fwork:Destroy()
end
firework.Activated:Connect(function()
	if debounce == false then
		Launch()
	end
end)

Can you debug? Check output for anything, add print(timeCooldown) after each time cooldown is set.

I fixed it, I just deleted all the code and redid it but instead I separated the activated event and the movement in 2 separate scripts in the firework tool and the actual firework

1 Like