Ive got a debounce inide a AnimationTrack.Stopped event and even with the debounce the script still fires multiple times?
Anyone got any ideas?
Heres the code
Choke.Stopped:connect(function()
if TargetCharacter.Humanoid.Health <= 0 and KillDebounce == false then
print("EnemyKilledYeet")
KillDebounce = true
game.ReplicatedStorage.DataFile[Player.Name].DarthVaderKills.Value = game.ReplicatedStorage.DataFile[Player.Name].DarthVaderKills.Value + 1
game.ReplicatedStorage.DataFile[Player.Name].TotalKills.Value = game.ReplicatedStorage.DataFile[Player.Name].TotalKills.Value + 1
game.ReplicatedStorage.DataFile[Player.Name].ExperiencePoints.Value = game.ReplicatedStorage.DataFile[Player.Name].ExperiencePoints.Value + 50
EnemyKilled:FireClient(Player)
KillDebounce = false
end
for _, Parts in pairs(script.Parent:GetChildren()) do
MainPlayer.Parent.Humanoid.WalkSpeed = 20
MainPlayer.Parent.Humanoid.JumpPower = 75
if Parts and Parts:IsA("Part") or Parts:IsA("UnionOperation") or Parts:IsA("WedgePart") then
Parts.Transparency = 0
script.Parent.MainTrail.Trail.Enabled = true
if Parts.Name == "Handle" then
Parts.Transparency = 1
end
end
end
end)
Im sorry about some of the long lines of code getting cut off I dont know how to fix that but basically whats happening is I use the debounce so It doesnt add more than 1 point to the stats when you get a kill but sometimes it runs 5 times and sometimes it runs only 1 time. So I dont know, the debounce script isnt working so any ideas?
Thanks so much for your time and hopefully we can solve this question :)

6 comments
Ive never heard of delay before? Does that run everything below the code and wait on only that 1 line? Because I that is amazing if it does. Ive been wishing Studio had something like that forever Ive just never heard about it.
But also I added a wait after the print statement in my script and it still fires multiple times? Any ideas still?
May I add the first time I trigger the animation it never prints multiple times, but the second time running the animation it always triggers multiple times.
Like it does it in a pattern, it prints 1 time then 4 times then 1 time then 4 times. Its super weird and I dont know why but it always does it in that pattern.
Okay I tried out the delay part and it worked :) Yayyyy thanks man!
Glad you got it working. To let you know, 'delay' waits the specified amount of time before running the function you give it in a new coroutine. If you wanted to use 'wait', you'd need to put it right before the 'KillDebounce = false' line.