On tool activation the code below is supposed to play the swing animation, and then upon next activation the comboSwing animation. After the main chunk of code, I run a reset function that prevents combo to be playable, if the player has hesitated to activate the tool for too long. With this function, the problem is that you can spam the 2nd animation:
0:12 timestamp^
However, I think the core issue lies with the main chunk of code and has something to do with debounces being reset irrespectively of the task.wait() by the Counter part, because removing that reset function I mentioned results in a different issue:
Now, the 2nd animation doesn’t get reset and merges with the first one. As of my solutions, I’ve tried moving the Counter section to the main chunk (which handles the animations) for better control over the order, in which things proceed, but that results in yet different issue, as the 2nd animation never plays (yes, even after setting comboSwingDB = false and attackCount to 2 at the end of the 1st animation).
I would really appreciate a solution, as I’ve struggled with this problem for too long. Anyway, here’s the snippet:
local function resetCount()
swingDebounce = false
task.wait(1)
if attackCount == 2 then
comboSwingDebounce = false
attackCount = 1
end
end
weapon.Activated:Connect(function()
if swingDebounce or comboSwingDebounce then
return
end
hitHumanoids = {}
-- Picking animation
local anim = nil
if attackCount == 1 and swingDebounce == false then
anim = swingAnimationTrack
swingDebounce = true
anim:Play()
task.wait(anim.Length - 0.4)
elseif attackCount == 2 and comboSwingDebounce == false then
anim = comboSwingAnimationTrack
comboSwingDebounce = true
anim:Play()
task.wait(anim.Length - 0.4)
end
-- Counting
if attackCount == 2 then
attackCount = 1
comboSwingDebounce = false
elseif attackCount == 1 then
attackCount = 2
swingDebounce = false
end
resetCount()
end)