Roblox Studio error

LoadAnimation requires an Animation object

What LoadAnimation requires an Animation object means in Roblox Studio, the three things that cause it with the code that triggers each, and the fix for each one.

Updated 5 November 20263 min readErrorLuauWritten by

In short

animator:LoadAnimation(x) needs x to be an Animation object, the instance that holds an AnimationId. Passing the ID itself, as a string like "rbxassetid://507770239" or a number, stops with this error, and so does passing some other object that happens to be found under that name. Create an Animation (in the Explorer or with Instance.new("Animation")), set its AnimationId, and pass the Animation.

  • Pass the Animation object, not its ID.
  • If the error says requires the asset id to not be empty, the Animation exists but its AnimationId was never set.
  • Load on the Animator inside the Humanoid. Humanoid:LoadAnimation is deprecated.
On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
Players.Builderman.PlayerScripts.Wave:9: LoadAnimation requires an Animation object

Other forms of the same message:

  • LoadAnimation requires the asset id to not be empty

An Animation object is a small pointer to an animation asset. LoadAnimation reads it and returns an AnimationTrack, the thing you call Play and Stop on. Without an Animation there is nothing to read, so the call is refused before anything loads.

This is a different problem from Failed to load animation with sanitized ID, where the Animation is fine but Roblox will not let your game use that asset.

Causes and fixes

Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.

The animation ID was passed instead of an Animation

It looks natural to hand the ID straight to LoadAnimation, and some older snippets show it that way. The function takes an object, not text.

Breaks LocalScript in StarterCharacterScripts named Wave
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") :: Humanoid
local animator = humanoid:WaitForChild("Animator") :: Animator

-- a string, not an Animation: LoadAnimation requires an Animation object
local track = animator:LoadAnimation("rbxassetid://507770239" :: any)
track:Play()

Create an Animation, set its AnimationId to the ID, and load the Animation. Make it once and reuse the track, rather than loading again on every key press.

Fixed LocalScript in StarterCharacterScripts named Wave
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") :: Humanoid
local animator = humanoid:WaitForChild("Animator") :: Animator

local waveAnimation = Instance.new("Animation")
waveAnimation.AnimationId = "rbxassetid://507770239"

local track = animator:LoadAnimation(waveAnimation)
track:Play()

A LocalScript in StarterCharacterScripts runs again for every new character, so the track is loaded fresh after each respawn. The animation script guide plays one on a key press.

The name found something that is not an Animation

script:WaitForChild("Run") returns whatever child is called Run. If that is a StringValue holding the ID, a Folder, or a KeyframeSequence from the Animation Editor, it is not an Animation.

Breaks LocalScript in StarterCharacterScripts named Run
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = (character:WaitForChild("Humanoid") :: Humanoid):WaitForChild("Animator") :: Animator

-- "Run" here is a StringValue that holds the ID: LoadAnimation requires an Animation object
local run = script:WaitForChild("Run")
local track = animator:LoadAnimation(run :: any)
track:Play()

Replace the child with an Animation (hover over the script, click +, insert Animation, paste the ID into AnimationId), and check its class in code so a mistake gives a clear warning.

Fixed LocalScript in StarterCharacterScripts named Run
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = (character:WaitForChild("Humanoid") :: Humanoid):WaitForChild("Animator") :: Animator

local run = script:WaitForChild("Run")
if run:IsA("Animation") then
	local track = animator:LoadAnimation(run)
	track:Play()
else
	warn("[Run] script.Run is a " .. run.ClassName .. ", not an Animation")
end

The Animation has no AnimationId (asset id empty)

A new Animation starts with an empty AnimationId. Loading it gives LoadAnimation requires the asset id to not be empty. It also happens when the ID is set from an attribute or a table entry that turned out to be missing.

Breaks LocalScript in StarterCharacterScripts named Dance
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = (character:WaitForChild("Humanoid") :: Humanoid):WaitForChild("Animator") :: Animator

local dance = Instance.new("Animation")
dance.AnimationId = script:GetAttribute("DanceId") or "" -- attribute missing
-- LoadAnimation requires the asset id to not be empty
animator:LoadAnimation(dance):Play()

Set the ID before loading, and check it is not empty when it comes from data.

Fixed LocalScript in StarterCharacterScripts named Dance
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = (character:WaitForChild("Humanoid") :: Humanoid):WaitForChild("Animator") :: Animator

local danceId = script:GetAttribute("DanceId")
if typeof(danceId) == "string" and danceId ~= "" then
	local dance = Instance.new("Animation")
	dance.AnimationId = danceId
	animator:LoadAnimation(dance):Play()
else
	warn("[Dance] set a DanceId attribute on this script, such as rbxassetid://507771019")
end

Fix it in your place

Paste the error, RoCode fixes it in your place

Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.

For example: Players.Builderman.PlayerScripts.Wave:9: LoadAnimation requires an Animation object

RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.

How to find the line that causes it

  1. Click the red line in Output to open the script at the LoadAnimation call.
  2. Above it, add print(typeof(x), x) for what you pass. An Animation prints Instance; then check x.ClassName is Animation and x.AnimationId is not empty.

Questions

How do I load an animation by ID in Roblox?

Create an Animation with Instance.new("Animation"), set AnimationId to "rbxassetid://" followed by the number, then call animator:LoadAnimation(animation) on the Animator inside the Humanoid and :Play() the track it returns.

Is Humanoid:LoadAnimation deprecated?

Yes. Roblox marks it deprecated in favour of Animator:LoadAnimation. Use the Animator that Roblox puts inside every character's Humanoid.

Why does my animation play only for me?

Tracks played on your own character through its Animator replicate to other players. If others cannot see it, check you used the Animator Roblox created, not one a LocalScript made, and that the animation belongs to you or your group.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It reads the script in your open place, creates the Animation with the right ID and loads it on the Animator.

Sources and further reading

How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 5 November 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the message strings in Roblox Studio itself (macOS build installed 2 November 2026) and the Animator:LoadAnimation reference on 5 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

More Roblox errors

All Roblox Studio errors

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.