I need to add a debounce to my punch script that uses 3 different animations to make a charged effect. The problem is that you can just go around the charging by spam clicking.
local anim = script:WaitForChild(“Punch”)
local anim1 = script:WaitForChild(“PunchReady1”)
local anim2 = script:WaitForChild(“PunchLaunch”)
local anim3 = script:WaitForChild(“PunchHold”)
local Punchdo = humanoid:LoadAnimation(anim)
local PunchReady = humanoid:LoadAnimation(anim1)
local PunchLaunch = humanoid:LoadAnimation(anim2)
local PunchHold = humanoid:LoadAnimation(anim3)
local debounce = false
script.Parent.Activated:Connect(function()
if not debounce then
debounce = true
Holding.Value = true
PunchReady:Play()
PunchReady.Stopped:Wait()
PunchHold:Play()
wait (2)
debounce = false
end
end)
script.Parent.Deactivated:Connect(function()
Holding.Value = false
PunchHold:Stop()
PunchLaunch:Play()
end)