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

How do i use an if statement to check if an animation is playing?

anim:Play()
swingsound:Play()
if not anim.IsPlaying  then


--Coder_1

How do i check if the anim is playing my anim is already defined inside of my code and im trying to do an if statement to see if its possible for me to check if it finished playing so i can fire my event.

2 answers

Use the stopped event. An if statement would require a loop.

anim:Play()
swingsound:Play()
anim.Stopped:Connect(function()
--stuff
end)

2 comments

0

Alright will try!

0

Is there also an ended function for animations? And does an animation ending fire the stopped event?

You also could just check what animation are playing in the humanoid :

for i, Animation in pairs(humanoid:GetPlayingAnimationTracks()) do
	if Animation then
	
	end
end

You could then use that like this :

for i, Animation in pairs(humanoid:GetPlayingAnimationTracks()) do
	if Animation then
		if Animation.AnimationId == anim.AnimationId then
			--run rest of script here
		end
	end
end

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