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

How to make an animation play only if another animation is done playing?

Lunge has to finish first before playing Slash even when clicked too fast.

local debounce = false 

script.Parent.Equipped:Connect(function(mouse)
	local wield = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)
	
	wield:Play()
	
	script.Parent.Activated:Connect(function()
        local wield = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)
        local lunge = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Lunge)
        local lungePause = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.LungePause)
		
		wield:Stop()
		lunge:Play()
		wait(lunge.Length)
		lunge:Stop()
		lungePause:Play()
	end)
	
	script.Parent.Deactivated:Connect(function()
        local wield = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)
        local lungePause = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.LungePause)
		local slash = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Slash)
		
		lungePause:Stop()
		slash:Play()
		wait(slash.Length)
		slash:Stop()
		wield:Play()	
	end)
end)

1 comment

0

nvm the debounce

1 answer

you could wait until the Stopped event fires on the animation track of the first animation..

like this:

animationTrack1.Stopped:Wait()
animationTrack2:Play()

the above will wait until the first animation(animationTrack1) finishes, then plays the second one(animationTrack2)

1 comment

0

i don't know how to apply it to my code. please enlighten me.

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