"Invalid Animation ID"?

I was trying to make a script that plays an animation for the player who touched it. My script is below. For some reason, it’s erroring with Invalid animation id '<erro: unknown AssetId protocol>':. Any suggestions?

And just to clarify, it’s erroring on line 5, where I try to load the animation onto the Animator already inside of all humanoids.

This animation does exist. Don’t question the name

script.Parent.Touched:Connect(function(otherPart)
	if otherPart.Parent:FindFirstChild("Humanoid") then
		local animation = Instance.new("Animation")
		animation.AnimationId = 6345594954
		local animationTrack = otherPart.Parent.Humanoid.Animator:LoadAnimation(animation)
		animation:Play()
	end
end)

I think that’s why, try doing this instead:

animation.AnimationId = "rbxassetid://6345594954"

Animation | Documentation - Roblox Creator Hub.

3 Likes

For anyone coming here in the future my final code is:

local debounce = false

script.Parent.Touched:Connect(function(otherPart)
	if otherPart.Parent:FindFirstChild("Humanoid") then
		if debounce == false then
			local animation = Instance.new("Animation")
			animation.AnimationId = "rbxassetid://6345594954"
			local animationTrack = otherPart.Parent.Humanoid.Animator:LoadAnimation(animation)
			animationTrack:Play()
			debounce = true
		end
	end
end)