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

why doesnt the debounce affect this animation?

local clicked = false
tool.Activated:connect(function()
	if not clicked then
		clicked = true
	if swing1 and humanoid and humanoid.Health > 0 then
		local swingAnim = humanoid:LoadAnimation(swing1)
		swingAnim:Play()
	end
	clicked = false
	end
end)

1 answer

The method Play only plays the animation but also continues the code so you are resetting the denounce not waiting till the animation finishes.

local clicked = false
 local swingAnim  = nil -- store animation
tool.Activated:connect(function()
	
--check animation status
if swingAnim   ~= nil then
	clicked = swingAnim:IsPlaying () -- now check that the animation has finished
end
	
    if not clicked then
	        clicked = true
		    if swing1 and humanoid and humanoid.Health > 0 then
		        local swingAnim = humanoid:LoadAnimation(swing1)
		        swingAnim:Play()
		    end
	    -- clicked = false we now don't need this
    end
end)

Hope this helps comment if you need any more info

2 comments

0

turns out it was because i didnt add a wait()

0

just a note but wait() is not exact u chould use tick() to accreatly mesure time

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