Animation onto an
Animator, returning an
AnimationTrack. Used to load animations on locally controlled models (such as player characters) from the server.
Model is considered locally controlled if it has network ownership of the model, clients have network ownership of the local character model by default and other models can be assigned to a different client using
It is best practice to only animate a model from the server if the server has network ownership, and for this reason most developers will not need to use the
Animator/LoadAnimation function as they can load animations directly from the
Note if the server has network ownership of the model, and the
Humanoid was created on the server, then
Animator/LoadAnimation does not need to be used as
LoadAnimation can be used directly from the
AnimationController on the server.
This code sample includes a function that can be used to play an animation on a locally controlled model (such as a player character) from the server.
local function playAnimationFromServer(character, animation) local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then -- need to use animation object for server access local animator = humanoid:FindFirstChildOfClass("Animator") if animator then local animationTrack = animator:LoadAnimation(animation) animationTrack:Play() return animationTrack end end end