Variable not updating

I am trying to add a cooldown to activating the tool, but the variable cd is not updating
this is running in a localscript

script.Parent.Activated:Connect(function()
	local cd = false
	if cd == false then
		local anim = script.Parent.Slash
		local hum = char.Humanoid
		local track = hum:LoadAnimation(anim)
		track:Play()
		blocking = false
		cd = true
		wait(2)
		cd = false
	end
	if cd == true then
	end
end)

You are setting cd to false every time the code runs, move this variable outside of this function

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.