Cannot load AnimationClipProvider service error

Hi,

I’m making a class module that handles class abilities and stuff. I am having a problem where the client side isn’t able to load the animations properly after dying.

Here’s the client sided module:

local Client = {}
Client.__index = Client

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService('RunService')

local RaycastHitbox = require(ReplicatedStorage.Sources.Utility.RaycastHitboxV4)

function Client.new(Tool: Tool, Character: Model, Animations: any)
	local self = setmetatable({},Client)
	RunService.Stepped:Wait() -- thought this would fix it
	
	self.Tool = Tool:Clone()
	self.Character = Character
	self.Humanoid = Character:WaitForChild("Humanoid")
	
	self.Animations = Animations
	self.LoadedAnimations = {}
	
	self.LoadedAnimations.Equip = self.Humanoid.Animator:LoadAnimation(self.Animations.Equip)
	self.LoadedAnimations.Idle = self.Humanoid.Animator:LoadAnimation(self.Animations.Idle)

	self.Hitbox = RaycastHitbox.new(Tool.Handle)
	self.Hitbox.Visualizer = true
	
	self:Equip()
	
	return self
end

function Client:Equip()
	self.LoadedAnimations.Equip:Play()
	self.LoadedAnimations.Idle:Play()
end

function Client:M1()

end

return Client

Connection:

local Knit = require(game:GetService("ReplicatedStorage").Packages.Knit)

local ClassController = Knit.CreateController{
	Name = "ClassController"
}

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Animations: Folder = ReplicatedStorage.Assets.Animations
local Tools: Folder = ReplicatedStorage.Assets.ClassTools
local AbilityClasses: Folder = ReplicatedStorage.Sources.Classes.Ability

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

function ClassController:SelectClass(Class: string)
	if not AbilityClasses[Class] then
		warn(Class, "was not found.")
		return
	end

	if not Animations[Class] then
		warn(Class, "animations were not found.")
		return
	end

	if not AbilityClasses[Class] then
		warn(Class, "module was not found.")
		return
	end

	if not Tools[Class] then
		warn(Class, "tool was not found.")
		return
	end
	
	Humanoid:SetAttribute("Class", Class)
	
	local ClassTool = Tools[Class]
	local ClassAnimations = Animations[Class]
	local ClassModule = require(AbilityClasses[Class]).new(ClassAnimations,ClassTool, Character)
	
	ClassModule:Init()
	print(ClassModule)
end

function ClassController:Reset(Class: string)

end

Player.CharacterAppearanceLoaded:Connect(function() 
ClassController:SelectClass("Reaper") -- test
end)

ClassController:SelectClass("Reaper") -- init
return ClassController

Add a wait or use CharacterAppearanceLoaded insead of CharacterAdded.

Still having the same issue even after that

Make sure that you’re loading the animations while the character is a descendant of workspace, otherwise this error will show up

Edit for more info:

@Remingling

1 Like

Sorry about the late reply but do you know any way I can check if the player is a descendant of workspace

Never mind. I think the real problem was the animations were being reloaded everytime I died. I only need to load them once and play them after their death. So what I did was this:

local Client = {}
Client.__index = Client

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local RunService = game:GetService('RunService')

local RaycastHitbox = require(ReplicatedStorage.Sources.Modules.RaycastHitboxV4)

function Client.new(Tool: Tool, Character: Model, Animations: any)
	local self = setmetatable({},Client)
	RunService.Stepped:Wait() -- thought this would fix it
	
	self.Tool = Tool:Clone()
	self.Character = Character
	self.Humanoid = Character:WaitForChild("Humanoid")
	
	self.LoadedAnimations = {}
	
	for _, anim in pairs(Animations:GetChildren()) do 
		self.LoadedAnimations[anim.Name] =  self.Humanoid.Animator:LoadAnimation(anim)
	end
	
	self.Hitbox = RaycastHitbox.new(Tool.Handle)
	self.Hitbox.Visualizer = true
	
	self:Equip()
	
	Players.LocalPlayer.CharacterAdded:Connect(function()
		self:Equip()
	end)
	
	return self
end

function Client:Equip()
	self.LoadedAnimations.Equip:Play()
	self.LoadedAnimations.Idle:Play()
end

function Client:M1()

end


return Client

This removes the cannot load animation error, BUT

it literally doesn’t even play the animations anymore… I tried adding a print and the print goes through the connection. I have no idea why the animation isn’t playing no more.

I would suggest adding a print statement inside of this for loop in your script as a check to make sure that all animations have finished loading and were successfully converted into AnimationTracks