How would I find a cetain animation using GetPlayingAnimationTracks()?

I have been trying to find a certain animation with GetPlayingAnimationTracks(), but all I get are things like “animation1”, and “animation”, but I want the name of the animation. This is the script and the output of the test. wat
Any ideas on how exactly I can get this to find the name rather than just “animation1” and “animation”?

2 Likes

You should be able to use the Animation property of AnimationTrack to get the correct name.

print(v.Animation.Name)

2 Likes

To add on to this, to get the name of the animation asset which is uploaded to roblox, you would use marketplace service.

print(game:GetService("MarketplaceService"):GetProductInfo(v.Animation.AnimationId).Name)
EDIT: Use my response below because this errors.
print(game:GetService("MarketplaceService"):GetProductInfo(tonumber(v.Animation.AnimationId:sub(14))).Name)

2 Likes

Darn, none of those worked. Spooce, yours came back with the same output, and emperor, yours came back with a error saying,“21:42:35.555 - Unable to cast string to int64”.

Ahh sorry, you need to make it cut out the rbxassetid://
print(game:GetService("MarketplaceService"):GetProductInfo(tonumber(v.Animation.AnimationId:sub(14))).Name)

4 Likes

Can you explain why you want the name of the animation?
Maybe there’s a better way to do what you’re actually trying to do.

1 Like

I want it so I can stop a certain animation.

I would compare the animation id’s instead of the name to stop a certain animation.
if v.Animation.AnimationId == "rbxassetid://ANIMATIONIDHERE" then v:Stop() end

4 Likes

Oof! Thanks it works now!

A post was merged into an existing topic: Off-topic and bump posts

I’m very late. I was having this problem before I discouvered that I was getting things like “Animation” or “Animation1” because I didn’t rename the animation when I created it.

with “error”

local newAnim = Instance.new(“Animation”)
newAnim.AnimationId = “rbxassetid://somid”

			local newAnimation = Animator:LoadAnimation(newAnim)
			newAnimation:Play()

local newAnim = Instance.new(“Animation”)
newAnim.AnimationId = “rbxassetid://somid”
newAnim.Name = “WalkAnim”

			local newAnimation = Animator:LoadAnimation(newAnim)
			newAnimation:Play()

and after I got the Humanoid.Animator:GetPlayingAnimationTracks() it was named as WalkAnim

1 Like