Why do I keep getting the error "LoadAnimation requires the asset id to not be empty"?

I’m trying to play an animation but keep getting the “LoadAnimation requires the asset id to not be empty” error.
How do I fix this?

anim.AnimationId = "rbxassetid://12088152379" -- id here
anim.Name = 'Anim'
anim.Parent = script.Parent

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	anim:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

-- Connecting Motor6D locally

local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)

script.Parent.Equipped:Connect(function()
	anim:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

All help is appreciated

you missed a line to paste the id
image
image

I just did that and now I am getting the error
Play is not a valid member of Animation “Animation” - Client - LocalScript:28
Stack Begin - Studio
Script ‘Players.Froyo1002YT.Backpack.Pistol.LocalScript’, Line 28
here’s my code.

-- LocalScript under the tool:
-- Animation playing
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://12088152379" -- id here
anim.Name = 'Anim'
anim.Parent = script.Parent

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	anim:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

-- Connecting Motor6D locally

local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://12088152379" -- id here
anim.Parent = script.Parent

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)

script.Parent.Equipped:Connect(function()
	anim2:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim2:Stop()
end)
--12088152379

I don’t really understand the error sorry maybe somebody else can help

1 Like

Ok thanks for trying!
I’ll try to find help!
:smiley:

1 Like

When you load an animation using humanoid, it returns a object which you can call play on. You dont call play on the animation object when you load it, you have to use the one the humanoid:LoadAnimation() returned

Meaning instead of doing anim2:Play() or anim:Play(), you would call load:Play(). Also recommend you to name the loaded animations from humanoid:LoadAnimation to something then load

– Connecting Motor6D server-side

local anim = Instance.new(“Animation”)
anim.AnimationId = “rbxassetid://12088152379” – id here
anim.Name = ‘Anim’
anim.Parent = script.Parent

script.Parent.Equipped:Connect(function(mouse)
anim:Play()
end)

script.Parent.Unequipped:Connect(function(mouse)
anim:Stop()
end)

– Connecting Motor6D server-side

local anim = script.Parent.Parent.Anim – Find Animation in Item’s Folder

script.Parent.Equipped:Connect(function(mouse)
anim:Play()
end)

script.Parent.Unequipped:Connect(function(mouse)
anim:Stop()
end)

local anim = Instance.new(“Animation”, script.Parent)
anim.AnimationId = “rbxassetid://12088152379”

This is where you were going wrong. AnimationId is a string and is not an integer.