Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Animation Debounce not changing value?

I made a function in a local script that plays animations along with a debounce so that you cannot play the same animation within a second of the animation playing. Here is the Local Script function:

local function PlayAttackAnimation(AnimationTrack)
        local Debounce

        if Debounce == true then return end

	AnimationTrack.Looped = false

	AnimationTrack:Play()

        Debounce = true
	wait(1)
        Debounce = false
end

What's happening is that the Debounce is not changing at all. Any solutions?

1 answer

✓ Accepted answer

The reason for this is because you've put the debounce in the function, each time you call the function it issues a new debounce since that's what you're telling the script to do.

Try put the debounce outside the function like so:

local Debounce
local function PlayAttackAnimation(AnimationTrack)
	if Debounce == true then return end
	AnimationTrack.Looped = false
	AnimationTrack:Play()
	Debounce = true
	wait(1)
	Debounce = false
end

1 comment

0

Thanks!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.