Cannot load the AnimationClipProvider Service

Hello

Recently I have encountered this error Cannot load the AnimationClipProvider Service; attached to the following public method:

function ClientGunClass:PreloadAnimations(animations: { Animation })
	local Humanoid = LocalPlayer.Character.Humanoid :: Humanoid
	for _, animationObject in pairs(animations) do
		RunService.RenderStepped:Wait()
		self.animationsLoaded[animationObject.AnimationId] = Humanoid:LoadAnimation(animationObject)
	end
end

The class on initialisation works fine, however since the class is re-started when the player respawns (the root is attached in a LocalScript of a tool), the second time around it throws this error.

I am presuming it is something to do with the fact the animations are preloaded on each spawn, but I cannot make it globalised because the humanoid resets.

I have tried waiting an abundance of seconds before firing the preloading method, however regardless of the length of the delay, this error is thrown without anomalies. I originally thought it was because of old variables, but this cannot be the case.

The public method is ran in a LocalScript of a tool, the scope can be found here:

do
    ...
    --[[ Animations ]]--
    --[[ type "Animations" is a folder, and each child of
    that folder is an Animation Instance ]]--
	ClientGunClass:PreloadAnimations { Animations.Rest, Animations.Armed, Animations.Pull }
end

Thanks

4 Likes

instead of
Humanoid:LoadAnimation(animationObject)
try
Humanoid:WaitForChild("Animator"):LoadAnimation(animationObject)

1 Like

Wasn’t the right solution but I figured it was because the Humanoid was being defined too early in the scope, fixed code is:

for _, animationObject in pairs(animations) do
	RunService.RenderStepped:Wait()
	self.animationsLoaded[animationObject.AnimationId] = LocalPlayer.Character.Humanoid:WaitForChild("Animator"):LoadAnimation(animationObject)
end

ppreciate the response though :pray::pray:

3 Likes

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