Error when loading animation bundle owned by roblox "Failed to load animation with sanitized ID"

Im currently making an animator bundle tester and have come across this problem where when i try to load an animation from the bundle (retrieved from AssetService:GetBundleDetailsAsync(...)) and trying to load it as such:

CurrentAnimationId = HumanoidDescription[AnimationType]
Animation.AnimationId = "rbxassetid://" ..CurrentAnimationId
AnimationTrack = Animator:LoadAnimation(Animation) -- Error here

it throws out "Failed to load animation with sanitized ID rbxassetid://18538133604: AnimationClip loaded is not valid."
yet the the humanoidDescription parented to a character plays the animation without any problem

  • Yes the animationId is valid and works under he humanoidDescription
  • I looked through other posts and they can be summed up as: You don’t own the animation, id is invalid
    but im sure the id is valid but im not sure if the fact it’s roblox owned and not mine is the problem
1 Like

alright here’s the solution i found:
The problem was the fact i didn’t own the animation what you want to do is use InsertService and call InsertService:LoadAsset(AnimationId) from the server and extract the animation from there, here’s the function i got for extracting the animation (Worked in all test cases):

local AnimationTypes = {
	"IdleAnimation",
	"WalkAnimation",
	"RunAnimation",
	"JumpAnimation",
	"FallAnimation",
	"ClimbAnimation",
	"SwimAnimation",
}

local AnimationNamesList = {
	"idle",
	"walk",
	"run",
	"jump",
	"fall",
	"climb",
	"swim"
}

use the tables above to get the animationName and use the function below to extract the animation object

local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")

function GetLoadedAnimation(AnimationModel: Model, AnimationName)
	local KeyFrameSequence = AnimationModel:FindFirstChildWhichIsA('KeyframeSequence')
	
	if KeyFrameSequence then
		local HashId = KeyframeSequenceProvider:RegisterKeyframeSequence(KeyFrameSequence)
		local Animation = Instance.new('Animation')
		Animation.AnimationId = HashId
		return Animation
	end
	
	local AnimationsList = AnimationModel:WaitForChild('R15Anim'):WaitForChild(AnimationName):GetChildren()

	local TopWeight = 0
	local TopWeightAnimation

	if (#AnimationsList > 1) then
		for _, Animation in AnimationsList do
			local Weight = Animation:WaitForChild('Weight', 3)
			if Weight and (Weight.Value > TopWeight) then
				TopWeight = Weight.Value
				TopWeightAnimation = Animation
			end
		end
	else
		TopWeightAnimation = AnimationsList[1]
	end
	
	return TopWeightAnimation
end

and lastly here’s the server-side code i’m using to retrieve the animations (Wouldn’t really recommend using remoteFunctions but it is what it is):

local InsertService = game:GetService('InsertService')

function YieldData(func, ...)
	local Data
	local success = false
	local SearchIndex = 1
	local args = {...}

	while (not success) do
		success = pcall(function()
			Data = func(table.unpack(args))
		end)
		if (success) then break end
		SearchIndex += 1
		task.wait(SearchDelay)
	end

	return Data
end

local LoadedAnimations = {}
GetAnimation.OnServerInvoke = function(Player, AnimationId)
	if (not AnimationId) then Player:Kick() end
	
	AnimationId = tonumber(AnimationId)
	local Animation = LoadedAnimations[AnimationId]
	if (Animation) then return Animation end
	
	Animation = YieldData(InsertService.LoadAsset, InsertService, AnimationId)
	Animation.Parent = Animations
	LoadedAnimations[AnimationId] = Animation
	return Animation
end

Make sure to cache animations in case of multiple requests

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.