I ran into a very silly problem and I dont know why…
After LoadCharacter() manually, waited for the Character, waited for the Humanoid then I called a module function.
Even the module function again, waits for Character, Humanoid, Animator, and even waits the animation inside the model Im giving to player…
All the prints shows exactly what should do, the character is found, the humanoid is found, the animator is found, the animation inside the model is found…
BUT, when I LoadAnimation(), the console says “Cannot load AnimationClipProvider Service”
local chary = player.Character or player.CharacterAdded:Wait()
warn(chary)
warn(chary.Humanoid)
warn(chary.Humanoid.Animator)
warn(myItem:WaitForChild("Idle"))
local ItemAnim = chary:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(myItem:WaitForChild("Idle"))
I found this post that suggest to add a wait, before loading the animation, totally makes sense… but I already waited for all instances needed for the process… what else should I wait? just a random wait(10) ?.. which actually make it works… When I wait 10 seconds, the animation works… but I dont wanna wait a “random” time, just hoping the animation works, what Im missing in this chain of waits? what else to wait to actually make the animation to work?
I solved this by adding a line before the animation loading by RunService… RS.Stepped:Wait()
And now I guess everything makes sense… but I dont like it…
local itemAnim = nil
function onItemAdded(item)
local char = player.Character or player.CharacterAdded:Wait()
itemAnim = char:WaitForChild(“Humanoid”):WaitForChild(“Animator”):LoadAnimation(item:WaitForChild(“Idle”))
end
if player.Character then
onItemAdded(player.Character:FindFirstChild(“Item”))
else
player.CharacterAdded:Connect(function()
onItemAdded(player.Character:FindFirstChild(“Item”))
end)
end
Also, make sure you are using the right casing and that the animation exists.
Yup, I solved it by waiting a step of RunService, kinda make sense and kinda weird too, even if all instances are loaded, Character, Humanoid, Animator and the Animation, it was not working, by waiting one step of RunService its fixed.
Its server sided. When player joins AutoLoad/Spawn of character is disabled, then after reading all datastores correctly LoadCharacter() triggers, when character is fully loaded LoadAnimation() triggers, just before the LoadAnimation() I added RunService.Stepped:Wait(), and works nicely.
Glad it’s working now, was having the same issue with some guns that I ported to remote modules so nobody can steal the code and can be updated across all of my games. In the middle of making a system for a group and small stuff like that can get annoying sometimes
It really does, sometimes small stuff that is supposed to be quick and easy to do, turns into big silly issues where I get stucked for more time than I expected…