Roblox Animations

sentinelcore/roblox-skills/roblox-animations

作者 sentinelcoref2b1910a7fb898ed35cf2f856e2a2e48e38276bf無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Use when working with Roblox animation systems including playing, stopping, or blending animations on Humanoid characters or non-Humanoid models, handling AnimationTrack events, replacing default character animations, or debugging animation priority and blending issues.

AI 產生的概覽

Roblox 動畫系統參考指南:在 Humanoid 與非 Humanoid 模型上載入、播放、混合與替換動畫。

功能
此技能是一份 Roblox 動畫 API 參考文件。它說明 Animation、Animator、AnimationController 與 AnimationTrack 等核心物件,並介紹如何載入、播放、停止、循環與混合動畫軌道。內容也涵蓋動畫優先順序、標記事件、替換角色預設動畫,以及常見錯誤與其修正方式。
適用情境
適用於撰寫或除錯 Roblox 動畫程式碼的情境,例如在角色或道具上播放、停止動畫,處理 AnimationTrack 事件,替換角色預設動畫,或排查動畫優先順序與混合問題。
執行需求
不需要任何工具、套件或憑證;僅為說明文件,不附帶指令碼。使用前提是熟悉 Roblox Studio 與 Luau 程式撰寫。

Roblox Animations Reference

Core Objects

ObjectPurpose
AnimationAsset reference — holds AnimationId
AnimatorLives inside Humanoid or AnimationController; loads and drives tracks
AnimationControllerReplaces Humanoid for non-character rigs
AnimationTrackReturned by LoadAnimation; controls playback

Where to Run Animation Code

ScenarioScript TypeLocation
Local player characterLocalScriptStarterCharacterScripts
NPC / server-owned modelScriptInside model or ServerScriptService

Never play player character animations from a Script — they will not replicate correctly to the local client.


Loading and Playing Animations

lua
-- LocalScript in StarterCharacterScriptslocal character = script.Parentlocal animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local animation = Instance.new("Animation")animation.AnimationId = "rbxassetid://1234567890"
local track = animator:LoadAnimation(animation)
track:Play()                      -- default fade-in (0.1s), weight 1, speed 1track:Play(0.1, 1, 0.5)          -- fadeTime, weight, speed
track:AdjustSpeed(1.5)           -- change speed while playingtrack:AdjustWeight(0.5, 0.2)     -- weight 0.5, fade over 0.2s
track:Stop()                      -- default fade-out (0.1s)track:Stop(0.5)                   -- fade out over 0.5s

AnimationTrack Events

lua
-- Fires after fade-out completestrack.Stopped:Connect(function()    print("Animation finished")end)
-- Use :Once for one-shot cleanuptrack.Stopped:Once(function()    cleanup()end)
-- Fires when a named keyframe marker is reached-- Marker names are set in the Roblox Animation Editortrack:GetMarkerReachedSignal("FootStep"):Connect(function(paramString)    playFootstepSound()end)

Looped vs One-Shot

PropertyLoopedOne-Shot
track.Loopedtruefalse
Set inAnimation Editor (loop toggle)Animation Editor
Override at runtimetrack.Looped = falsetrack.Looped = true
Stops automaticallyNo — must call track:Stop()Yes — after one cycle
lua
-- Force a looped animation to play oncetrack.Looped = falsetrack:Play()track.Stopped:Once(function() print("Done") end)

Animation Priority and Blending

Priority controls which tracks win on contested joints. Higher priority overrides lower.

Idle < Movement < Action < Action2 < Action3 < Action4 < Core
lua
idleTrack.Priority   = Enum.AnimationPriority.IdlerunTrack.Priority    = Enum.AnimationPriority.MovementattackTrack.Priority = Enum.AnimationPriority.Action
idleTrack:Play()runTrack:Play()     -- overrides idle on shared jointsattackTrack:Play()  -- blends on top for joints it owns

Weight adjusts influence when two tracks share the same priority:

lua
trackA:Play(0, 0.6)  -- weight 0.6trackB:Play(0, 0.4)  -- weight 0.4 — blended on shared joints

Humanoid vs AnimationController

Humanoid (characters and humanoid NPCs)

lua
local animator = character:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")local track = animator:LoadAnimation(animation)track:Play()

AnimationController (props, vehicles, creatures)

lua
local controller = model:FindFirstChildOfClass("AnimationController")local animator = controller:FindFirstChildOfClass("Animator")if not animator then    animator = Instance.new("Animator")    animator.Parent = controllerendlocal track = animator:LoadAnimation(animation)track:Play()

Replacing Default Character Animations

The Animate LocalScript in the character holds animation references. Modify its AnimationId values on CharacterAdded.

lua
-- LocalScript in StarterCharacterScriptslocal animate = script.Parent:WaitForChild("Animate")
local function replaceAnim(slotName, newId)    local slot = animate:FindFirstChild(slotName)    if slot then        local animObj = slot:FindFirstChildOfClass("Animation")        if animObj then animObj.AnimationId = newId end    endend
replaceAnim("idle",  "rbxassetid://111111111")replaceAnim("run",   "rbxassetid://222222222")replaceAnim("jump",  "rbxassetid://333333333")replaceAnim("fall",  "rbxassetid://444444444")replaceAnim("climb", "rbxassetid://555555555")

Available slots: idle, walk, run, jump, fall, climb, swim, swimidle, toolnone, toolslash, toollunge.


Stop All Playing Animations

lua
local function stopAll(animator, fadeTime)    for _, track in animator:GetPlayingAnimationTracks() do        track:Stop(fadeTime or 0.1)    endend

Quick Playback Reference

lua
track:Play(fadeTime, weight, speed)-- fadeTime  default 0.1   — blend-in seconds-- weight    default 1.0   — joint influence (0–1)-- speed     default 1.0   — playback rate
track.TimePosition   -- current position in seconds (read/write)track.Length         -- total duration in secondstrack.IsPlaying      -- booltrack.Looped         -- bool (override allowed at runtime)track.Priority       -- Enum.AnimationPrioritytrack.WeightCurrent  -- actual blended weight right nowtrack.WeightTarget   -- target weight after fade

Upper-Body Only Animations

Priority blending affects all joints an animation touches. To play a wave only on the arms while legs animate from run/idle, the animation itself must be authored to only key upper-body bones (leave lower-body joints unkeyed in the Animation Editor). There is no runtime API to mask joints — the solution is in the animation asset, not the script.


Common Mistakes

MistakeFix
Playing character animations in a ScriptUse LocalScript in StarterCharacterScripts
LoadAnimation called on Humanoid (deprecated)Call on Animator instead
Two animations fighting on same jointsAssign different Priority values
Stopped fires immediatelyAnimation has zero length or wrong Looped setting
GetMarkerReachedSignal never firesMarker name misspelled, or animation not re-uploaded after adding markers
NPC animation not visible to other clientsPlay from a Script (server), not LocalScript
AnimationController track won't playMissing Animator child inside AnimationController

來源與署名

來源:sentinelcore/roblox-skills位於roblox-animations提交f2b1910

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架