Why is my animation script getting this error?

Im trying to make my own animation script and I’ve been getting this weird error even though I have a animation that is in existance.

Error

  15:55:49.945  Invalid animation id '<error: unknown AssetId protocol>':   -  Client - Animator:23
  15:55:49.945  Stack Begin  -  Studio
  15:55:49.945  Script 'Workspace.NubblyFry.Animator', Line 23  -  Studio - Animator:23
  15:55:49.945  Stack End  -  Studio

Script

--\\ Variables //--
local character = script.Parent

local idle = Instance.new("Animation")
idle.AnimationId = "8883367895"
idle.Parent = game:GetService("ReplicatedStorage")

local walk = Instance.new("Animation")
walk.AnimationId = "8897350611"
walk.Parent = game:GetService("ReplicatedStorage")

local humanoid = character:FindFirstChildOfClass("Humanoid")

--\\ Main Stream //--

if humanoid then
	local animator = humanoid:FindFirstChildOfClass("Animator")
	
	if animator then
		if humanoid.WalkSpeed == 0 then
			local animationTrack = animator:LoadAnimation(idle)
			
			animationTrack:Play()
		else
			if humanoid.WalkSpeed ~= 0 then
				local animationTrack = animator:LoadAnimation(walk)
				
				animationTrack:Play()
			end
		end
	end
end
1 Like

The AnimationId property needs to have the prefix “rbxassetid://” at the start of the string.

Example: "8883367895""rbxassetid://8883367895"

1 Like

That made it work but, for some reason, the walk animation overrides everything, and the idle animation never gets played.

1 Like