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

Why is my animation playing multiple times, even with debounce on?

https://giphy.com/gifs/MBfpCpfLly2Ib2wase https://giphy.com/gifs/MBfpCpfLly2Ib2wase

When I spam e, you can see the animation starting multiple times. When I press e once it plays once. What could be the problem? Is there something wrong with my debounce?

local Player = game:GetService("Players").LocalPlayer
--print(Player)
 
local rp = game:GetService("ReplicatedStorage")
local Character =  Player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local animation = workspace.Animation
animation.AnimationId = "http://www.roblox.com/asset/?id=5313493309"
local animationTrack = humanoid:LoadAnimation(animation)
local Debris = game:GetService("Debris")
local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
local knockback = rp:WaitForChild("KnockBack")
 
local UIS = game:GetService("UserInputService")

local push = rp:WaitForChild("Push")
local RemoteEvent = rp:WaitForChild("RemoteEvent")
 
local debounce = false
local debounce = false

UIS.InputBegan:Connect(function(input,isTyping)
    if isTyping then
        return
    elseif input.KeyCode == Enum.KeyCode.E then
		if debounce == false then       
			--print"push Fired"
			animationTrack:Play()
			wait(0.5)
			push:FireServer(Player)
			debounce = true
			wait(2)
			debounce = false
		end
    end
end)

1 answer

✓ Accepted answer

you have local debounce line twice and u should wait until the animation is done

animationTrack.Stopped:wait() use this as the wait between the debounce

4 comments

0

oh, the second line of debounce isnt there, I pasted it wrong

0

yea, i dont think that worked,. thanks anyways tho

0

put a print inside if, does actually fire when ur still doing the animation

0

oh, I changed it and it worked, thanks

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