I made an animation that makes the school bus model move.
I want it to move when the game is running, but it doesn’t work. I attached the bus animation and the code I wrote. busAnimation.rbxm (1.7 KB) schoolbus.rbxm (120.4 KB)
local animation = script:WaitForChild(‘Animation’)
local humanoid = script.Parent:WaitForChild(‘Humanoid’)
local dance = humanoid:LoadAnimation(animation)
dance:Play()
1. The model needs to be unanchored. You can weld all the parts together and keep it from moving by creating a primary part unrelated to the animation and anchoring it.
I recommend using an AnimationController rather than a humanoid for non-character models. It gets rid of the health bar and other unneeded values.
Regardless if you choose the Humanoid or the AnimationController, you need to call :LoadAnimation() on the Animator, not the Humanoid or the AnimationController as it is deprecated. The Animator is automatically made by the humanoid on startup, and is generated by the AnimationController when attempting to call its only function.
Revised example code:
--this will yield the same results more efficiently. make sure anchored and CanCollide are off for everything. (Some parts can be collidable, and if it becomes a problem just set some parts in a collisiongroup.)
local animation = script:WaitForChild("Animation")
local animControl = script.Parent:WaitForChild("AnimationController") --assuming you replaced the humanoid and manually added an animator
local animator = animControl:WaitForChild("Animator")
local dance = animator:LoadAnimation(animation)
dance:Play()