I made a Custom rig with animations in it but I don’t know how to play the animation. I used
local animation = script:WaitForChild(‘Animation’)
local humanoid = script.Parent:WaitForChild(‘Humanoid’)
local dance = humanoid:LoadAnimation(animation)
dance:Play()
but it doesn’t work. I’m not sure if Im supposed to put Humanoid in the model
A rig’s hierarchy should look something like this:
Model
Humanoid/AnimationController
Animator
Part(s)
(ideally Motor6Ds would go here but it doesn't really matter apart from organizational purposes)
You should be using the animator object to load the animation, not the humanoid, and the humanoid should be inside of the model in which everything else is located.
First things first. You are not defining the “dance” animation. Try this:
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7853253557"
local humanoid = script.Parent:WaitForChild("Humanoid")
local track
track = humanoid:LoadAnimation(animation)
track.Priority = Enum.AnimationPriority.Action -- either action, core, idle, or movement
track.Looped = false
track:Play()
Also sometimes with animations, If you do not own the animation, It will not work. try checking if you own the animation before running the code again.