Detect if an animation is loaded

local humanoid = script.Parent.Parent.Parent:FindFirstChild("Humanoid")

if humanoid.AnimationPlayed == '507771019' then
    print('animation playing')
end

I made the player load this animation and wanted to make a script that detects if this animation is currently loaded but I dont get the print

1 Like

The animation object has a property which shows if it is loaded or not.
Animation.IsLoaded
It is represented using a boolean value.
true if it is loaded
false if not

2 Likes

will this work if im asking for a specific ID like the one shown in the script above?

ok so, im trying to detect if the player is currently doing the /e dance animation ( as a test ), how would I do that?

AnimationTrack | Roblox Creator Documentation will return 0 until the animation has fully loaded. So you have to check if the length is > 0

4 Likes

From here you can check which one is playing
IsPlaying is a property of the animations to check if an animation is playing.

1 Like

it doesnt seem to be printing, i do /e dance but I dont get the print to confirm that is working

here’s the script im currently using

local players = game:GetService("Players")

players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect (function(character)
		if character.Animate then
			if character.Animate.Dance then
				if character.Animate.Dance.Animation1.IsPlaying == true 
					or character.Animate.Dance.Animation2.IsPlaying == true 
					or character.Animate.Dance.Animation3.IsPlaying == true then
					
					print('Dancing!')
					
				end
			end
		end
	end)
end)

It is because this event only fires when player is added.
Try something like(inside the player added function)
player.Chatted:Connect(function()
the code inside
end)

1 Like

tried, sort of worked but I got this as a result

" Workspace.ShinonArtZ.LeftFoot.Mist.Script:13: attempt to index nil with ‘Animate’ "

sure thing, ill keep working on it myself too and see if I can find a solution

wait(5)

local character = script.Parent.Parent.Parent


if character.Animate then
	if character.Animate.dance then
		if character.Animate.dance.Animation1.IsPlaying == true 
			or character.Animate.dance.Animation2.IsPlaying == true 
			or character.Animate.dance.Animation3.IsPlaying == true then

			print('Dancing!')

		end
	end
end

script works when it comes to finding the character.Animate but there’s an issue again
" IsPlaying is not a valid member of Animation "Workspace.ShinonArtZ.Animate.dance.Animation1 "

I am sorry for not responding after my last reply.
It was night for me and I had to sleep.
Today morning I tried seeing the issue and found that Animation and Animation tracks are different and IsPlaying is a property of Animation track and not the animation itself.

I have been trying to work out the solution.
Sorry for anything misleading.
I post if I get anything helpful and something that can solve the problem.

No worries I made the script work myself I will post it in the morning, just a heads-up tho it’s not very optimized and will lag the game a lot so I need to go around it in a different way like using remote events

Here’s a video of it working tho!

https://i.gyazo.com/5b529833fdf0ca79299a5c90c56b5063.mp4

1 Like
while true do
	animationLength = animationTrack.Length
	if animationLength > 0 then 
		break 
	end
	
	-- Loop until the animation is fully loaded
	task.wait(0.01)
end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.