KeyframeReached working but not setting debounce variable to true

It prints C, but doesn’t set CanHit to true

''local Sabre = script.Parent

local Model = Sabre:WaitForChild(“Sabre”)

local Blade = Model:WaitForChild(“Blade”)
local Hit = Blade:WaitForChild(“Hit”)
local Swing = Blade:WaitForChild(“Swing”)
local Trail = script:WaitForChild(“Trail”)

local Hilt = Model:WaitForChild(“Hilt”)

local Anim = 1
local CanHit = false
local Debounce = false

local function Punish(Part)
local Humanoid = Part.Parent:FindFirstChildWhichIsA(“Humanoid”)
if Humanoid and CanHit then
CanHit = false
Humanoid:TakeDamage(20)
Hit:Play() --HitSound(Id:7125960488)
end
end

Blade.Touched:Connect(Punish)

Sabre.Equipped:Connect(function()
local Character = Sabre.Parent
local Humanoid = Character.Humanoid

local Motor6D = Instance.new("Motor6D",Hilt)
Motor6D.Part0 = Character["Right Arm"]
Motor6D.Part1 = Hilt

local IdleAnimation = Humanoid:LoadAnimation(script.idle)
IdleAnimation:Play()
Sabre.Unequipped:Connect(function()
	Motor6D:Destroy()
	IdleAnimation:Stop()
end)

end)

Sabre.Activated:Connect(function()
local Character = Sabre.Parent
local Humanoid = Character.Humanoid

if not Debounce then
	Debounce = true
	Trail.Enabled = true
	Swing:Play()
	if Anim == 1 then
		Anim = 2
		local SwingA = Humanoid:LoadAnimation(script.slashRight)
		SwingA:Play()
		SwingA.KeyframeReached:Connect(function(CanHit)
			print("C")
			CanHit = true
		end)
		SwingA.Stopped:Connect(function()
			print("S")
			CanHit = false
			Trail.Enabled = false
		end)
		wait(1)
		Debounce = false
	elseif Anim == 2 then
		Anim = 1
		local SwingB = Humanoid:LoadAnimation(script.slashDown)
		SwingB:Play()
		SwingB.KeyframeReached:Connect(function(CanHit)
			print("C")
			CanHit = true
		end)
		SwingB.Stopped:Connect(function()
			print("S")
			CanHit = false
			Trail.Enabled = false
		end)
		wait(1)
		Debounce = false
	end
end

end)
‘’

I dont know how to make the code go tothgether