I’m trying to animate a dragon in a game that I am making. I have created the animation and uploaded it to Roblox, but when I try to apply it to the dragon itself, it does not run. There are no errors, the code just doesn’t work.
Here is the code, the script is directly under the dragon model.
local dragon = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8305318154"
local animationController = Instance.new("AnimationController", dragon)
local animator = Instance.new("Animator", animationController)
local animationTrack = animator:LoadAnimation(animation)
wait(5)
animationTrack:Play()
Why are you creating an animator instance.
If you’re trying to make a dummy instance to move then you can just load the animation onto it’s humanoid such as like this
local dragon = script.Parent
local humanoid = dragon.Humanoid
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8305318154"
animation.Parent = script
humanoid:LoadAnimation(script.Animation):Play()
Note that this will only work IF you have set an animation to the dragon with the dragon rig and if you inserted a humanoid. + You do not need to create an animator instance as it’s already a default setting for players and models do not require to use them.
Players can also have animations loaded to their humanoid but it’s better to do so with the animator
sometimes animations with low priority get overridden by another animation. But that’s probably not your issue if your model does not have other animations.
Since it’s not an issue with you not having usable code. It’s an issue with something else. And we have no way of figuring it out without checking out your model since I can’t think of any past issues similar to yours.
Either way it’s not a scripting support issue it seems. I wish you the best of luck.
Okay, for anyone who was curious about what I was doing wrong, just like @LadyAka said, it had nothing to do with the script.
Actually, I didn’t rig my model properly. For anyone like me who has no clue how to rig and animate, I would highly recommend this tutorial I found and used on YouTube:
But anyway, thanks to everyone for your help! The animation works now.