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
local InsertService = game:GetService("InsertService")-- Load a model for demonstrationlocal npcModel = InsertService:LoadAsset(516159357):GetChildren()npcModel.Name = "NPC"npcModel.PrimaryPart.Anchored = truenpcModel:SetPrimaryPartCFrame(CFrame.new(0, 5, 0))npcModel.Parent = workspace-- Replace the humanoid with an animationcontrollerlocal humanoid = npcModel:FindFirstChildOfClass("Humanoid")humanoid:Destroy()local animationController = Instance.new("AnimationController")animationController.Parent = npcModel-- Create and load an animationlocal animation = Instance.new("Animation")animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emotelocal animationTrack = animationController:LoadAnimation(animation)-- Play the animationanimationTrack:Play()