#How do i use debounce to delay my animation input detection scripts from all playing at the sametime

51 messages · Page 1 of 1 (latest)

wary bluff
crimson nexus
#

you didnt do the "if debounce == false then"

#

think of it as a on off switch, you first are setting it false (line 9) then you need to make sure it's off before turning it on, (if debounce == false then debounce = true) then after the function set it back to false, because you cant turn the switch on if its already on (debounce = false)

#

remove line 23, you already referenced it in line 9

abstract temple
#

i always see ppl use debounce

#

but tbh is much easier to use cooldown

#

its just a change of the variable name

#

but your brain will intepret it better

#

so local cooldown = false
if cooldown then return end
-- then you set start the cooldown
cooldown = true
task.wait(2) -- this is not prefered ig you should use task.spawn or task.delay(task.delay is much easier to understand since the parameter is just: task.delay(time, function() end)

abstract temple
#

i remember you

#

arent you the first person i talk to in this server 🥶

crimson nexus
#

when did you join

#

wait i can see

#

yeah i cant remember that far back crylaugh

crimson nexus
# wary bluff how do i stop this

this is using debounce, i never used cooldown before so idk which is better (but considering its just the name change i dont think they're any different)

local debounce = false

UIS. InputEnded: Connect(function(I,E)
    
    if debounce == false then debounce = true
        
        if E then return end
        
        for _, playingTrack in animator:GetPlayingAnimationTracks() do
            playingTrack:Stop(0)
            abilitytrack.Looped = false
        end
        abilitytrack:Play()
        
        task.delay(1, function()
            debounce = false
        end)
        print("punch")
        game.ReplicatedStorage.RemoteEvent:FireServer()
    end
end)
wary bluff
#

Ty

abstract temple
abstract temple
#

its just your brain intepret cooldown faster because its a more common word

hot frigate
#

debounce and cooldown isnt entirely the same

#

debounce is global cooldown to all moves

#

cooldown can be for each skill

wary bluff
#

Ok

#

So denounce should be in every Anim script

#

Since its global

hot frigate
#

wym

wary bluff
#

How is it global if I put it in one script

crimson nexus
#

global is a variable that can be accessed by code in the same script, not all scripts

#

correct me if im wrong idkk mann

#

wait so this can be confusing because as this guy said [image]

wary bluff
#

TY

abstract temple
#

oh never mind

#

i thought you said _G-

abstract temple
wary bluff
#

cooldown is a bool

#

and debounce is a bool right

#

aren't they the same thing only different by name

#

do bools do different things by name

#

my anims are still playing all at once

abstract temple
abstract temple
wary bluff
#

This value thingy is an error though

abstract temple
#

exactly