Animator not loading animation

Hello,
So I’m trying to make a randomized animation player for an NPC in a game. I try to load the animation with Animator:LoadAnimation() but an error pops up (picture below).
image

Here is the script that causes the error:

local dances = { -- There are some animation ids in here but they take up too much space so I deleted them
}

task.wait(0.5)

local animation = script:WaitForChild('Animation')
animation.AnimationId = dances[math.random(1, #dances)]
local humanoid = script.Parent:WaitForChild('Humanoid')
local dance = humanoid.Animator:LoadAnimation(animation)
dance:Play()

Here is an Id I used: 3333499508

I tried checking if the id was an animation using if MarketplaceService:GetProductInfo(Animation.AnimationId).AssetTypeId == 24 then but the error still occurred.
(*I checked in AssetType | Documentation - Roblox Creator Hub to see the Id types)

Any ideas?
Thank you!

1 Like

Hi! I was wondering but, did you try “rbxassetid://[Asset ID]” by any chance?

1 Like

Exactly as @RealCalculus Suggested!

local dances = {
     'rbxassetid://3333499508' -- Animation ID(Not Just the NumberID)
}
1 Like

No, I completely forgot about that! Thank you!

1 Like

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