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

How do i check if an animation is playing?

script.Parent.Activated:connect(function()
	swing = player.Character.Humanoid:LoadAnimation(Animation)
	swing:Play()
	if script.Parent.Equipped == false then
		swing:Stop()
	end 
	if player.Character.Animate.walk.WalkAnim.IsPlaying == true then
		swing1 = player.Character.Humanoid:LoadAnimation(Animation1)
		swing:Stop()
		swing:Play()
		
	end
	
	
end)

i run play solo and it says "isPlaying is not a valid member of animation"

1 answer

✓ Accepted answer

IsPlaying is not a member of Animation objects, it is a property of AnimationTracks.

If you don't have these tracks stored in a variable somewhere, then you can retrieve a list of all playing AnimationTracks on a given humanoid using the method GetPlayingAnimationTracks. We can then loop through this list and if we find an AnimationTrack created from the Animation object then that animation is playing:

local walking = false

for _, track in ipairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
	if track.Animation == player.Character.Animate.walk.WalkAnim then
		walking = true
	end
end

if walking then
	-- code
end

5 comments

0

Thank you so much, now my game dev isnt stopped XD Nuzzles

0

Glad to help :)

0

ok i have a problem, can i play two animations at the same time, lets say i want to play the sword swing animation while walking so the player notices no difference. do i set it at a different priority or something?

0

You can, but you have to exclude different joints or else one of them will overwrite the other: http://wiki.roblox.com/index.php?title=Animations#Exclusion

0

Just got a massive necrobump

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