So, for the third time, I made a local script that plays an animation when R is pressed, along with a function for debounce, so the animation is not spammable. Here is the animation debounce function, it does not change the value for debounce, but it runs waits according to the parameters. (LocalScript)
local function WaitDebounce(AnimationTrack,DebounceLength)
repeat wait() until AnimationTrack.IsPlaying == false
wait(DebounceLength)
end
Now, for the local script that runs the animations:(Same local script as before)
--Humanoid is already defined bc im too lazy to write
local Attack = game.ReplicatedStorage.Attack
local AttackTrack = Humanoid:LoadAnimation(Attack)
local UIS = game:GetService("UserInputService")
local AttackDebounce = false
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.R and AttackDebounce == false then
AttackTrack.Looped = false
AttackTrack:Play()
AttackDebounce = true
WaitDebounce(AttackTrack,0.5)
AttackDebounce = false
end
end)
When I run the scripts, everything works completely fine except for the Debounce. Does anybody have a solution?

5 comments
Ok i'll try it out in a few hours cause school lol
But this does seem like the only good answer
Thanks :)
I have one request, can u copy and paste your answer into roblox studio, bind the animation to the animationtrack and test if the debounce works?
Sorry it was late for me :)