I am trying to make a punching script that makes it so the punch animation is not able to be spammed, i tried using debounce which kind of worked but the animation still plays halfway when you spam it, this is my code:
local db = false
punch.Activated:Connect(function()
if db == false then
db = true
PunchAnimTrack:Play()
db = false
debounce = false
end
That’s because you’re not waiting for the animation track to finish. your debounce just enables, plays the animation, then disables right away.
You need to add the .Ended() event into your code:
local db = false
punch.Activated:Connect(function()
if db == false then
db = true
PunchAnimTrack:Play()
PunchAnimTrack.Ended:Wait()
db = false
debounce = false
end
end)