An object which allows animations to be loaded and applied to a character or model in place of a Humanoid when a Humanoid is not needed. Creates an Animator and loads animations to update Motor6Ds of said character to react in the way that is described within the animation asset referenced by an Animation object.
Should I load an Animation on the client or server?
If an Animator is a descendant of a Humanoid or AnimationController in a Player's Character then animations started on that Player's client will be replicated to the server and other clients.
If the Animator is not a descendant of a player character, its animations must be loaded and started on the server to replicate.
The Animator object must be initially created on the server and replicated to clients for animation replication to work at all. If an Animator is created locally, then AnimationTracks loaded with that Animator will not replicate.
Both Humanoid:LoadAnimation() and AnimationController:LoadAnimation() will create an Animator if one does not already exist. When calling LoadAnimation from LocalScripts you need to be careful to wait for the Animator to replicate from the server before calling LoadAnimation if you want character animations to replicate. You can do this with WaitForChild("Animator").
- Animation Editor to explore this powerful built-in plugin for creating custom animations
- Using Animations to learn how to add pre-built and custom animations to your game
1local InsertService = game:GetService("InsertService")23-- Load a model for demonstration4local npcModel = InsertService:LoadAsset(516159357):GetChildren()5npcModel.Name = "NPC"6npcModel.PrimaryPart.Anchored = true7npcModel:SetPrimaryPartCFrame(CFrame.new(0, 5, 0))8npcModel.Parent = workspace910-- Replace the humanoid with an animationcontroller11local humanoid = npcModel:FindFirstChildOfClass("Humanoid")12humanoid:Destroy()13local animationController = Instance.new("AnimationController")14animationController.Parent = npcModel1516-- Create and load an animation17local animation = Instance.new("Animation")18animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote19local animationTrack = animationController:LoadAnimation(animation)2021-- Play the animation22animationTrack:Play()