Unable to cast value to Object error when creating a track for my animation

When I try to create an animation track for my NPC, I get the error “Unable to cast value to object”, as far as I’m aware I wrote everything correctly, and I can’t seem to find anyone on dev forums who is in my situation.

local walkAnim = Instance.new('Animation')
local idleAnim = Instance.new('Animation')
local attackAnim = Instance.new('Animation')
walkAnim.AnimationId = "rbxassetid://11883196748"
idleAnim.AnimationId = "rbxassetid://11885586876"
attackAnim = "rbxassetid://11883199942"

local walkTrack = script.Parent:WaitForChild("Humanoid"):LoadAnimation(walkAnim)
local idleTrack = script.Parent:WaitForChild("Humanoid"):LoadAnimation(idleAnim)
local attackTrack = script.Parent:WaitForChild("Humanoid"):LoadAnimation(attackAnim)
walkTrack.Looped = true
idleTrack.Looped = true
attackTrack.Looped = false

Did you forget to put .AnimationId here?!

1 Like

thank you

(fill out thir,ty character limit here wooooow yay woohoo)

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