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

How to retrieve Animation Id from player?

I was wondering if there is a way to grab the players Animation Id from their Humanoid?

My script makes the player dance but I want to make a script which repeatedly checks to make sure it's the correct animation. Is this possible to maybe print the animations id?

local humanoid = workspace["CrazyCorrs"].Humanoid
local AnimationTracks = humanoid:GetPlayingAnimationTracks()

for i, track in pairs (AnimationTracks) do
	print(track) 
end

I attempted this but it prints "Animation" and "Animation1" and not the Id?

3 comments

0

AnimationTracks don't return IDs.

0

In order to get the ID you have to use Animation.AnimationId.

0

How do I do that? humanoid:Animation isn't a think is it?

2 answers

✓ Accepted answer

AnimationTracks have a property named Animation, which is a reference to the animation that the track is associated with. AnimationTracks do not have an AnimationId property, but Animations do. In order to find the ID you have to use the Animation property:

local humanoid = workspace["CrazyCorrs"].Humanoid
local AnimationTracks = humanoid:GetPlayingAnimationTracks()
for _, track in pairs(AnimationTracks) do
	print(track.Animation.AnimationId)
end
local humanoid = workspace["CrazyCorrs"].Humanoid
local AnimationTracks = humanoid:GetPlayingAnimationTracks()

for i, track in pairs (AnimationTracks) do
	--MY CHANGE IS HERE!!
    local animationobject = track.Animation
    local animationid = animationobject.AnimationId
    print(animationid)
end

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